Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
66.67% |
16 / 24 |
|
60.00% |
12 / 20 |
|
8.11% |
3 / 37 |
|
12.50% |
1 / 8 |
CRAP | |
0.00% |
0 / 1 |
| DoctrineUser | |
66.67% |
16 / 24 |
|
60.00% |
12 / 20 |
|
8.11% |
3 / 37 |
|
12.50% |
1 / 8 |
166.09 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getIdentityId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getCreatedAt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getUpdatedAt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getAvatar | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| toDomain | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| fromDomain | |
81.82% |
9 / 11 |
|
84.62% |
11 / 13 |
|
6.67% |
2 / 30 |
|
0.00% |
0 / 1 |
46.84 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\User\Infrastructure\Persistence\Doctrine\Entity; |
| 4 | |
| 5 | use App\Shared\Domain\Model\EntityId; |
| 6 | use App\Shared\Domain\Model\StoredFile; |
| 7 | use App\Shared\Infrastructure\Persistence\Doctrine\Entity\DoctrineStoredFile; |
| 8 | use App\User\Domain\Model\User; |
| 9 | use Doctrine\ORM\Mapping as ORM; |
| 10 | |
| 11 | /** |
| 12 | * @author Wilhelm Zwertvaegher |
| 13 | */ |
| 14 | |
| 15 | #[ORM\Entity] |
| 16 | #[ORM\Table(name: "users")] |
| 17 | class DoctrineUser |
| 18 | { |
| 19 | #[ORM\Id, ORM\Column(type: "string", length: 36)] |
| 20 | private string $id; |
| 21 | |
| 22 | #[ORM\Column(type: "string", length: 36, unique: true)] |
| 23 | private string $identityId; |
| 24 | |
| 25 | #[ORM\Column(type: 'datetime_immutable')] |
| 26 | private \DateTimeImmutable $createdAt; |
| 27 | |
| 28 | #[ORM\Column(type: 'datetime_immutable')] |
| 29 | private \DateTimeImmutable $updatedAt; |
| 30 | |
| 31 | #[ORM\OneToOne(targetEntity: DoctrineStoredFile::class)] |
| 32 | #[ORM\JoinColumn(name: "avatar_id", referencedColumnName: "id", nullable: true)] |
| 33 | private ?DoctrineStoredFile $avatar; |
| 34 | |
| 35 | public function __construct(/*string $id, string $identityId, \DateTimeImmutable $createdAt, \DateTimeImmutable $updatedAt, ?DoctrineStoredFile $avatar*/) |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | public function getId(): string |
| 40 | { |
| 41 | return $this->id; |
| 42 | } |
| 43 | |
| 44 | public function getIdentityId(): string |
| 45 | { |
| 46 | return $this->identityId; |
| 47 | } |
| 48 | |
| 49 | public function getCreatedAt(): \DateTimeImmutable |
| 50 | { |
| 51 | return $this->createdAt; |
| 52 | } |
| 53 | |
| 54 | public function getUpdatedAt(): \DateTimeImmutable |
| 55 | { |
| 56 | return $this->updatedAt; |
| 57 | } |
| 58 | |
| 59 | public function getAvatar(): ?DoctrineStoredFile |
| 60 | { |
| 61 | return $this->avatar; |
| 62 | } |
| 63 | |
| 64 | public function toDomain(): User |
| 65 | { |
| 66 | return new User( |
| 67 | EntityId::fromString($this->id), |
| 68 | EntityId::fromString($this->identityId), |
| 69 | $this->createdAt, |
| 70 | $this->updatedAt, |
| 71 | $this->avatar?->toDomain() |
| 72 | ); |
| 73 | } |
| 74 | |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 79 | throw new \InvalidArgumentException('Mapping a user should not change its id or identityid'); |
| 80 | } |
| 81 | |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 83 | throw new \InvalidArgumentException('User seems to have an avatar but not doctrine stored file'); |
| 84 | } |
| 85 | |
| 86 | $this->id = $user->getId(); |
| 87 | $this->identityId = $user->getIdentityId(); |
| 88 | $this->createdAt = $user->getCreatedAt(); |
| 89 | $this->updatedAt = $user->getUpdatedAt(); |
| 90 | $this->avatar = $doctrineStoredFile; |
| 91 | return $this; |
| 92 | } |
| 93 | } |
Below are the source code lines that represent each code path as identified by Xdebug. Please note a path is not
necessarily coterminous with a line, a line may contain multiple paths and therefore show up more than once.
Please also be aware that some paths may include implicit rather than explicit branches, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 37 | } |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 79 | throw new \InvalidArgumentException('Mapping a user should not change its id or identityid'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 83 | throw new \InvalidArgumentException('User seems to have an avatar but not doctrine stored file'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 86 | $this->id = $user->getId(); |
| 87 | $this->identityId = $user->getIdentityId(); |
| 88 | $this->createdAt = $user->getCreatedAt(); |
| 89 | $this->updatedAt = $user->getUpdatedAt(); |
| 90 | $this->avatar = $doctrineStoredFile; |
| 91 | return $this; |
| 92 | } |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 83 | throw new \InvalidArgumentException('User seems to have an avatar but not doctrine stored file'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 86 | $this->id = $user->getId(); |
| 87 | $this->identityId = $user->getIdentityId(); |
| 88 | $this->createdAt = $user->getCreatedAt(); |
| 89 | $this->updatedAt = $user->getUpdatedAt(); |
| 90 | $this->avatar = $doctrineStoredFile; |
| 91 | return $this; |
| 92 | } |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 79 | throw new \InvalidArgumentException('Mapping a user should not change its id or identityid'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 83 | throw new \InvalidArgumentException('User seems to have an avatar but not doctrine stored file'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 86 | $this->id = $user->getId(); |
| 87 | $this->identityId = $user->getIdentityId(); |
| 88 | $this->createdAt = $user->getCreatedAt(); |
| 89 | $this->updatedAt = $user->getUpdatedAt(); |
| 90 | $this->avatar = $doctrineStoredFile; |
| 91 | return $this; |
| 92 | } |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 83 | throw new \InvalidArgumentException('User seems to have an avatar but not doctrine stored file'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 86 | $this->id = $user->getId(); |
| 87 | $this->identityId = $user->getIdentityId(); |
| 88 | $this->createdAt = $user->getCreatedAt(); |
| 89 | $this->updatedAt = $user->getUpdatedAt(); |
| 90 | $this->avatar = $doctrineStoredFile; |
| 91 | return $this; |
| 92 | } |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 79 | throw new \InvalidArgumentException('Mapping a user should not change its id or identityid'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 83 | throw new \InvalidArgumentException('User seems to have an avatar but not doctrine stored file'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 86 | $this->id = $user->getId(); |
| 87 | $this->identityId = $user->getIdentityId(); |
| 88 | $this->createdAt = $user->getCreatedAt(); |
| 89 | $this->updatedAt = $user->getUpdatedAt(); |
| 90 | $this->avatar = $doctrineStoredFile; |
| 91 | return $this; |
| 92 | } |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 83 | throw new \InvalidArgumentException('User seems to have an avatar but not doctrine stored file'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 86 | $this->id = $user->getId(); |
| 87 | $this->identityId = $user->getIdentityId(); |
| 88 | $this->createdAt = $user->getCreatedAt(); |
| 89 | $this->updatedAt = $user->getUpdatedAt(); |
| 90 | $this->avatar = $doctrineStoredFile; |
| 91 | return $this; |
| 92 | } |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 79 | throw new \InvalidArgumentException('Mapping a user should not change its id or identityid'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 83 | throw new \InvalidArgumentException('User seems to have an avatar but not doctrine stored file'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 86 | $this->id = $user->getId(); |
| 87 | $this->identityId = $user->getIdentityId(); |
| 88 | $this->createdAt = $user->getCreatedAt(); |
| 89 | $this->updatedAt = $user->getUpdatedAt(); |
| 90 | $this->avatar = $doctrineStoredFile; |
| 91 | return $this; |
| 92 | } |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 83 | throw new \InvalidArgumentException('User seems to have an avatar but not doctrine stored file'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 86 | $this->id = $user->getId(); |
| 87 | $this->identityId = $user->getIdentityId(); |
| 88 | $this->createdAt = $user->getCreatedAt(); |
| 89 | $this->updatedAt = $user->getUpdatedAt(); |
| 90 | $this->avatar = $doctrineStoredFile; |
| 91 | return $this; |
| 92 | } |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 79 | throw new \InvalidArgumentException('Mapping a user should not change its id or identityid'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 83 | throw new \InvalidArgumentException('User seems to have an avatar but not doctrine stored file'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 86 | $this->id = $user->getId(); |
| 87 | $this->identityId = $user->getIdentityId(); |
| 88 | $this->createdAt = $user->getCreatedAt(); |
| 89 | $this->updatedAt = $user->getUpdatedAt(); |
| 90 | $this->avatar = $doctrineStoredFile; |
| 91 | return $this; |
| 92 | } |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 83 | throw new \InvalidArgumentException('User seems to have an avatar but not doctrine stored file'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 86 | $this->id = $user->getId(); |
| 87 | $this->identityId = $user->getIdentityId(); |
| 88 | $this->createdAt = $user->getCreatedAt(); |
| 89 | $this->updatedAt = $user->getUpdatedAt(); |
| 90 | $this->avatar = $doctrineStoredFile; |
| 91 | return $this; |
| 92 | } |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 79 | throw new \InvalidArgumentException('Mapping a user should not change its id or identityid'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 83 | throw new \InvalidArgumentException('User seems to have an avatar but not doctrine stored file'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 86 | $this->id = $user->getId(); |
| 87 | $this->identityId = $user->getIdentityId(); |
| 88 | $this->createdAt = $user->getCreatedAt(); |
| 89 | $this->updatedAt = $user->getUpdatedAt(); |
| 90 | $this->avatar = $doctrineStoredFile; |
| 91 | return $this; |
| 92 | } |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 83 | throw new \InvalidArgumentException('User seems to have an avatar but not doctrine stored file'); |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 86 | $this->id = $user->getId(); |
| 87 | $this->identityId = $user->getIdentityId(); |
| 88 | $this->createdAt = $user->getCreatedAt(); |
| 89 | $this->updatedAt = $user->getUpdatedAt(); |
| 90 | $this->avatar = $doctrineStoredFile; |
| 91 | return $this; |
| 92 | } |
| 61 | return $this->avatar; |
| 62 | } |
| 51 | return $this->createdAt; |
| 52 | } |
| 41 | return $this->id; |
| 42 | } |
| 46 | return $this->identityId; |
| 47 | } |
| 56 | return $this->updatedAt; |
| 57 | } |
| 66 | return new User( |
| 67 | EntityId::fromString($this->id), |
| 68 | EntityId::fromString($this->identityId), |
| 69 | $this->createdAt, |
| 70 | $this->updatedAt, |
| 71 | $this->avatar?->toDomain() |
| 72 | ); |
| 73 | } |
| 3 | namespace App\User\Infrastructure\Persistence\Doctrine\Entity; |
| 4 | |
| 5 | use App\Shared\Domain\Model\EntityId; |
| 6 | use App\Shared\Domain\Model\StoredFile; |
| 7 | use App\Shared\Infrastructure\Persistence\Doctrine\Entity\DoctrineStoredFile; |
| 8 | use App\User\Domain\Model\User; |
| 9 | use Doctrine\ORM\Mapping as ORM; |
| 10 | |
| 11 | /** |
| 12 | * @author Wilhelm Zwertvaegher |
| 13 | */ |
| 14 | |
| 15 | #[ORM\Entity] |
| 16 | #[ORM\Table(name: "users")] |
| 17 | class DoctrineUser |
| 18 | { |
| 19 | #[ORM\Id, ORM\Column(type: "string", length: 36)] |
| 20 | private string $id; |
| 21 | |
| 22 | #[ORM\Column(type: "string", length: 36, unique: true)] |
| 23 | private string $identityId; |
| 24 | |
| 25 | #[ORM\Column(type: 'datetime_immutable')] |
| 26 | private \DateTimeImmutable $createdAt; |
| 27 | |
| 28 | #[ORM\Column(type: 'datetime_immutable')] |
| 29 | private \DateTimeImmutable $updatedAt; |
| 30 | |
| 31 | #[ORM\OneToOne(targetEntity: DoctrineStoredFile::class)] |
| 32 | #[ORM\JoinColumn(name: "avatar_id", referencedColumnName: "id", nullable: true)] |
| 33 | private ?DoctrineStoredFile $avatar; |
| 34 | |
| 35 | public function __construct(/*string $id, string $identityId, \DateTimeImmutable $createdAt, \DateTimeImmutable $updatedAt, ?DoctrineStoredFile $avatar*/) |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | public function getId(): string |
| 40 | { |
| 41 | return $this->id; |
| 42 | } |
| 43 | |
| 44 | public function getIdentityId(): string |
| 45 | { |
| 46 | return $this->identityId; |
| 47 | } |
| 48 | |
| 49 | public function getCreatedAt(): \DateTimeImmutable |
| 50 | { |
| 51 | return $this->createdAt; |
| 52 | } |
| 53 | |
| 54 | public function getUpdatedAt(): \DateTimeImmutable |
| 55 | { |
| 56 | return $this->updatedAt; |
| 57 | } |
| 58 | |
| 59 | public function getAvatar(): ?DoctrineStoredFile |
| 60 | { |
| 61 | return $this->avatar; |
| 62 | } |
| 63 | |
| 64 | public function toDomain(): User |
| 65 | { |
| 66 | return new User( |
| 67 | EntityId::fromString($this->id), |
| 68 | EntityId::fromString($this->identityId), |
| 69 | $this->createdAt, |
| 70 | $this->updatedAt, |
| 71 | $this->avatar?->toDomain() |
| 72 | ); |
| 73 | } |
| 74 | |
| 75 | public function fromDomain(User $user, ?DoctrineStoredFile $doctrineStoredFile = null): self |
| 76 | { |
| 77 | if (isset($this->identityId) && !$user->getIdentityId()->valueEquals($this->identityId) || |
| 78 | isset($this->id) && !$user->getId()->valueEquals($this->id)) { |
| 79 | throw new \InvalidArgumentException('Mapping a user should not change its id or identityid'); |
| 80 | } |
| 81 | |
| 82 | if ($user->getAvatar() !== null && null === $doctrineStoredFile) { |
| 83 | throw new \InvalidArgumentException('User seems to have an avatar but not doctrine stored file'); |
| 84 | } |
| 85 | |
| 86 | $this->id = $user->getId(); |
| 87 | $this->identityId = $user->getIdentityId(); |
| 88 | $this->createdAt = $user->getCreatedAt(); |
| 89 | $this->updatedAt = $user->getUpdatedAt(); |
| 90 | $this->avatar = $doctrineStoredFile; |
| 91 | return $this; |
| 92 | } |