Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
50.00% |
5 / 10 |
|
50.00% |
5 / 10 |
CRAP | |
0.00% |
0 / 1 |
| User | |
50.00% |
5 / 10 |
|
50.00% |
5 / 10 |
22.50 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getUsername | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getEmail | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getPasswordHash | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isActive | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getCreatedAt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getUpdatedAt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getCreatedBy | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getOwner | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Modules\User\Domain\Model; |
| 6 | |
| 7 | use DateTimeImmutable; |
| 8 | |
| 9 | /** |
| 10 | * User Entity in Domain Layer (DDD). |
| 11 | * |
| 12 | * Pure PHP entity completely decoupled from framework and database details. |
| 13 | * |
| 14 | * @package App\Modules\User\Domain\Model |
| 15 | */ |
| 16 | final class User |
| 17 | { |
| 18 | /** |
| 19 | * User Entity constructor. |
| 20 | * |
| 21 | * @param int|null $id Unique user identifier. |
| 22 | * @param string $username Unique username. |
| 23 | * @param string $email Unique email address. |
| 24 | * @param string $passwordHash Hashed password. |
| 25 | * @param bool $isActive Account active flag. |
| 26 | * @param DateTimeImmutable|null $createdAt Creation timestamp. |
| 27 | * @param DateTimeImmutable|null $updatedAt Modification timestamp. |
| 28 | * @param int $createdBy Creator user ID. |
| 29 | * @param int $owner Record owner user ID. |
| 30 | */ |
| 31 | public function __construct( |
| 32 | private ?int $id, |
| 33 | private string $username, |
| 34 | private string $email, |
| 35 | private string $passwordHash, |
| 36 | private bool $isActive = true, |
| 37 | private ?DateTimeImmutable $createdAt = null, |
| 38 | private ?DateTimeImmutable $updatedAt = null, |
| 39 | private int $createdBy = 1, |
| 40 | private int $owner = 1 |
| 41 | ) { |
| 42 | } |
| 43 | |
| 44 | public function getId(): ?int |
| 45 | { |
| 46 | return $this->id; |
| 47 | } |
| 48 | |
| 49 | public function getUsername(): string |
| 50 | { |
| 51 | return $this->username; |
| 52 | } |
| 53 | |
| 54 | public function getEmail(): string |
| 55 | { |
| 56 | return $this->email; |
| 57 | } |
| 58 | |
| 59 | public function getPasswordHash(): string |
| 60 | { |
| 61 | return $this->passwordHash; |
| 62 | } |
| 63 | |
| 64 | public function isActive(): bool |
| 65 | { |
| 66 | return $this->isActive; |
| 67 | } |
| 68 | |
| 69 | public function getCreatedAt(): ?DateTimeImmutable |
| 70 | { |
| 71 | return $this->createdAt; |
| 72 | } |
| 73 | |
| 74 | public function getUpdatedAt(): ?DateTimeImmutable |
| 75 | { |
| 76 | return $this->updatedAt; |
| 77 | } |
| 78 | |
| 79 | public function getCreatedBy(): int |
| 80 | { |
| 81 | return $this->createdBy; |
| 82 | } |
| 83 | |
| 84 | public function getOwner(): int |
| 85 | { |
| 86 | return $this->owner; |
| 87 | } |
| 88 | } |