Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
83.33% |
5 / 6 |
CRAP | |
90.00% |
9 / 10 |
| Establishment | |
0.00% |
0 / 1 |
|
83.33% |
5 / 6 |
7.05 | |
90.00% |
9 / 10 |
| __construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| establishmentId | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| fromArray | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| toArray | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| equals | |
100.00% |
1 / 1 |
2 | |
100.00% |
3 / 3 |
|||
| __toString | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| <?php | |
| declare(strict_types=1); | |
| namespace App\Order\Domain\ValueObject; | |
| use App\Shared\ValueObjectInterface; | |
| use Assert\Assertion; | |
| final class Establishment implements ValueObjectInterface | |
| { | |
| private EstablishmentId $establishmentId; | |
| private function __construct(EstablishmentId $establishmentId) | |
| { | |
| $this->establishmentId = $establishmentId; | |
| } | |
| public function establishmentId(): EstablishmentId | |
| { | |
| return $this->establishmentId; | |
| } | |
| public static function fromArray(array $data): self | |
| { | |
| Assertion::uuid($data['uuid']); | |
| return new self(EstablishmentId::fromString($data['uuid'])); | |
| } | |
| public function toArray(): array | |
| { | |
| return [ | |
| 'uuid' => $this->establishmentId->toString(), | |
| ]; | |
| } | |
| public function equals(ValueObjectInterface $valueObject): bool | |
| { | |
| if (!$valueObject instanceof self) { | |
| return false; | |
| } | |
| return $this->toArray() === $valueObject->toArray(); | |
| } | |
| public function __toString(): string | |
| { | |
| return (string) json_encode($this->toArray()); | |
| } | |
| } |