Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
15 / 15 |
|
100.00% |
9 / 9 |
|
100.00% |
9 / 9 |
|
100.00% |
9 / 9 |
CRAP | |
100.00% |
1 / 1 |
| User | |
100.00% |
15 / 15 |
|
100.00% |
9 / 9 |
|
100.00% |
9 / 9 |
|
100.00% |
9 / 9 |
9 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| create | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getIdentityId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getCreatedAt | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getUpdatedAt | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getAvatar | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setAvatar | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| pullEvents | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\User\Domain\Model; |
| 4 | |
| 5 | use App\Shared\Domain\Event\DomainEvent; |
| 6 | use App\Shared\Domain\Model\ProducesDomainEvents; |
| 7 | use App\Shared\Domain\Model\StoredFile; |
| 8 | use App\Shared\Domain\Model\EntityId; |
| 9 | use App\User\Domain\Event\AvatarUpdatedEvent; |
| 10 | use App\User\Domain\Event\UserCreatedEvent; |
| 11 | use DateTimeImmutable; |
| 12 | |
| 13 | class User implements ProducesDomainEvents |
| 14 | { |
| 15 | /** |
| 16 | * @var array<DomainEvent> |
| 17 | */ |
| 18 | private array $events = []; |
| 19 | |
| 20 | |
| 21 | /** |
| 22 | * @param EntityId $id |
| 23 | * @param EntityId $identityId |
| 24 | * @param DateTimeImmutable $createdAt |
| 25 | * @param DateTimeImmutable $updatedAt |
| 26 | * @param StoredFile|null $avatar |
| 27 | */ |
| 28 | public function __construct( |
| 29 | private readonly EntityId $id, |
| 30 | private readonly EntityId $identityId, |
| 31 | private readonly DateTimeImmutable $createdAt, |
| 32 | private readonly DateTimeImmutable $updatedAt, |
| 33 | private readonly ?StoredFile $avatar = null |
| 34 | ) { |
| 35 | } |
| 36 | |
| 37 | public static function create( |
| 38 | EntityId $id, |
| 39 | EntityId $identityId, |
| 40 | DateTimeImmutable $createdAt, |
| 41 | DateTimeImmutable $updatedAt, |
| 42 | ?StoredFile $avatar = null |
| 43 | ): self { |
| 44 | $newUser = new self($id, $identityId, $createdAt, $updatedAt, $avatar); |
| 45 | $newUser->events = [new UserCreatedEvent($newUser)]; |
| 46 | return $newUser; |
| 47 | } |
| 48 | |
| 49 | public function getId(): EntityId |
| 50 | { |
| 51 | return $this->id; |
| 52 | } |
| 53 | |
| 54 | public function getIdentityId(): EntityId |
| 55 | { |
| 56 | return $this->identityId; |
| 57 | } |
| 58 | |
| 59 | public function getCreatedAt(): DateTimeImmutable |
| 60 | { |
| 61 | return $this->createdAt; |
| 62 | } |
| 63 | |
| 64 | public function getUpdatedAt(): DateTimeImmutable |
| 65 | { |
| 66 | return $this->updatedAt; |
| 67 | } |
| 68 | |
| 69 | public function getAvatar(): ?StoredFile |
| 70 | { |
| 71 | return $this->avatar; |
| 72 | } |
| 73 | |
| 74 | public function setAvatar(?StoredFile $avatar): self |
| 75 | { |
| 76 | $result = new User($this->id, $this->identityId, $this->createdAt, new DateTimeImmutable(), $avatar); |
| 77 | $result->events = [new AvatarUpdatedEvent($result)]; |
| 78 | return $result; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * @return array<DomainEvent> |
| 83 | */ |
| 84 | public function pullEvents(): array |
| 85 | { |
| 86 | $events = $this->events; |
| 87 | $this->events = []; |
| 88 | return $events; |
| 89 | } |
| 90 | } |
Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not
necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once.
Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 28 | public function __construct( |
| 29 | private readonly EntityId $id, |
| 30 | private readonly EntityId $identityId, |
| 31 | private readonly DateTimeImmutable $createdAt, |
| 32 | private readonly DateTimeImmutable $updatedAt, |
| 33 | private readonly ?StoredFile $avatar = null |
| 34 | ) { |
| 35 | } |
| 37 | public static function create( |
| 38 | EntityId $id, |
| 39 | EntityId $identityId, |
| 40 | DateTimeImmutable $createdAt, |
| 41 | DateTimeImmutable $updatedAt, |
| 42 | ?StoredFile $avatar = null |
| 43 | ): self { |
| 44 | $newUser = new self($id, $identityId, $createdAt, $updatedAt, $avatar); |
| 45 | $newUser->events = [new UserCreatedEvent($newUser)]; |
| 46 | return $newUser; |
| 47 | } |
| 71 | return $this->avatar; |
| 72 | } |
| 61 | return $this->createdAt; |
| 62 | } |
| 51 | return $this->id; |
| 52 | } |
| 56 | return $this->identityId; |
| 57 | } |
| 66 | return $this->updatedAt; |
| 67 | } |
| 86 | $events = $this->events; |
| 87 | $this->events = []; |
| 88 | return $events; |
| 89 | } |
| 74 | public function setAvatar(?StoredFile $avatar): self |
| 75 | { |
| 76 | $result = new User($this->id, $this->identityId, $this->createdAt, new DateTimeImmutable(), $avatar); |
| 77 | $result->events = [new AvatarUpdatedEvent($result)]; |
| 78 | return $result; |
| 79 | } |
| 3 | namespace App\User\Domain\Model; |
| 4 | |
| 5 | use App\Shared\Domain\Event\DomainEvent; |
| 6 | use App\Shared\Domain\Model\ProducesDomainEvents; |
| 7 | use App\Shared\Domain\Model\StoredFile; |
| 8 | use App\Shared\Domain\Model\EntityId; |
| 9 | use App\User\Domain\Event\AvatarUpdatedEvent; |
| 10 | use App\User\Domain\Event\UserCreatedEvent; |
| 11 | use DateTimeImmutable; |
| 12 | |
| 13 | class User implements ProducesDomainEvents |
| 14 | { |
| 15 | /** |
| 16 | * @var array<DomainEvent> |
| 17 | */ |
| 18 | private array $events = []; |
| 19 | |
| 20 | |
| 21 | /** |
| 22 | * @param EntityId $id |
| 23 | * @param EntityId $identityId |
| 24 | * @param DateTimeImmutable $createdAt |
| 25 | * @param DateTimeImmutable $updatedAt |
| 26 | * @param StoredFile|null $avatar |
| 27 | */ |
| 28 | public function __construct( |
| 29 | private readonly EntityId $id, |
| 30 | private readonly EntityId $identityId, |
| 31 | private readonly DateTimeImmutable $createdAt, |
| 32 | private readonly DateTimeImmutable $updatedAt, |
| 33 | private readonly ?StoredFile $avatar = null |
| 34 | ) { |
| 35 | } |
| 36 | |
| 37 | public static function create( |
| 38 | EntityId $id, |
| 39 | EntityId $identityId, |
| 40 | DateTimeImmutable $createdAt, |
| 41 | DateTimeImmutable $updatedAt, |
| 42 | ?StoredFile $avatar = null |
| 43 | ): self { |
| 44 | $newUser = new self($id, $identityId, $createdAt, $updatedAt, $avatar); |
| 45 | $newUser->events = [new UserCreatedEvent($newUser)]; |
| 46 | return $newUser; |
| 47 | } |
| 48 | |
| 49 | public function getId(): EntityId |
| 50 | { |
| 51 | return $this->id; |
| 52 | } |
| 53 | |
| 54 | public function getIdentityId(): EntityId |
| 55 | { |
| 56 | return $this->identityId; |
| 57 | } |
| 58 | |
| 59 | public function getCreatedAt(): DateTimeImmutable |
| 60 | { |
| 61 | return $this->createdAt; |
| 62 | } |
| 63 | |
| 64 | public function getUpdatedAt(): DateTimeImmutable |
| 65 | { |
| 66 | return $this->updatedAt; |
| 67 | } |
| 68 | |
| 69 | public function getAvatar(): ?StoredFile |
| 70 | { |
| 71 | return $this->avatar; |
| 72 | } |
| 73 | |
| 74 | public function setAvatar(?StoredFile $avatar): self |
| 75 | { |
| 76 | $result = new User($this->id, $this->identityId, $this->createdAt, new DateTimeImmutable(), $avatar); |
| 77 | $result->events = [new AvatarUpdatedEvent($result)]; |
| 78 | return $result; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * @return array<DomainEvent> |
| 83 | */ |
| 84 | public function pullEvents(): array |
| 85 | { |
| 86 | $events = $this->events; |
| 87 | $this->events = []; |
| 88 | return $events; |
| 89 | } |