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
3
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
2
1<?php
2
3declare(strict_types=1);
4
5namespace App\Domain\Auth\Data;
6
7final readonly class UserAuthData
8{
9    public function __construct(
10        public int $userId,
11        public ?int $investorId,
12        public string $username,
13        public string $email,
14        public string $passwordHash,
15        public string $role,
16        public bool $isActive,
17        public ?string $lastLogin,
18        public int $failedLoginAttempts,
19        public ?string $lockedUntil,
20    ) {}
21
22    /**
23     * @param array<string, mixed> $data
24     */
25    public static function fromRow(array $data): self
26    {
27        return new self(
28            userId: (int)$data['userId'],
29            investorId: !empty($data['investorId']) ? (int)$data['investorId'] : null,
30            username: (string)$data['username'],
31            email: (string)$data['email'],
32            passwordHash: (string)$data['passwordHash'],
33            role: (string)$data['role'],
34            isActive: (bool)$data['isActive'],
35            lastLogin: $data['lastLogin'] ?? null,
36            failedLoginAttempts: (int)$data['failedLoginAttempts'],
37            lockedUntil: $data['lockedUntil'] ?? null,
38        );
39    }
40}