Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
UserAuthData
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 fromRow
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Domain\Auth\Data;
6
7use App\Support\Row;
8
9final readonly class UserAuthData
10{
11    public function __construct(
12        public int $userId,
13        public ?int $investorId,
14        public string $username,
15        public string $email,
16        public string $passwordHash,
17        public string $role,
18        public bool $isActive,
19        public ?string $lastLogin,
20        public int $failedLoginAttempts,
21        public ?string $lockedUntil,
22    ) {}
23
24    /**
25     * @param array<mixed> $data
26     */
27    public static function fromRow(array $data): self
28    {
29        return new self(
30            userId: Row::int($data, 'userId'),
31            investorId: Row::nullableInt($data, 'investorId'),
32            username: Row::string($data, 'username'),
33            email: Row::string($data, 'email'),
34            passwordHash: Row::string($data, 'passwordHash'),
35            role: Row::string($data, 'role'),
36            isActive: Row::bool($data, 'isActive'),
37            lastLogin: Row::nullableString($data, 'lastLogin'),
38            failedLoginAttempts: Row::int($data, 'failedLoginAttempts'),
39            lockedUntil: Row::nullableString($data, 'lockedUntil'),
40        );
41    }
42}