Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
UserRecord
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
5 / 5
5
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
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getAuthKey
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 validateAuthKey
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 validatePassword
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Domain\Auth\Entity;
6
7use Yiisoft\Auth\IdentityInterface;
8
9 class UserRecord implements IdentityInterface
10{
11    public const STATUS_DELETED = 0;
12    public const STATUS_ACTIVE = 10;
13
14    public function __construct(
15        public int $id,
16        public string $username,
17        public string $email,
18        public string $passwordHash,
19        public string $authKey,
20        public int $status,
21        public int $createdAt,
22        public int $updatedAt
23    ) {}
24
25    public function getId(): ?string
26    {
27        return (string) $this->id;
28    }
29
30    public function getAuthKey(): ?string
31    {
32        return $this->authKey;
33    }
34
35    public function validateAuthKey(string $authKey): bool
36    {
37        return hash_equals($this->authKey, $authKey);
38    }
39
40    public function validatePassword(string $password): bool
41    {
42        return password_verify($password, $this->passwordHash);
43    }
44}