Total Complexity | 6 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
18 | class Domain |
||
19 | { |
||
20 | private const SEPARATOR = ':'; |
||
21 | |||
22 | /** @var Name */ |
||
23 | private $name; |
||
24 | |||
25 | /** @var Uuid */ |
||
26 | private $uuid; |
||
27 | |||
28 | public function __construct(Name $name, Uuid $uuid) |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @param string $string |
||
36 | * @return Domain |
||
37 | * @throws \Assert\AssertionFailedException |
||
38 | */ |
||
39 | public static function fromString(string $string): Domain |
||
40 | { |
||
41 | Assertion::notEmpty($string); |
||
42 | list($domainName, $uuid) = explode(self::SEPARATOR, $string); |
||
43 | |||
44 | return self::build($domainName, $uuid); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @param string $domainName |
||
49 | * @param string $uuid |
||
50 | * @return Domain |
||
51 | * @throws \Assert\AssertionFailedException |
||
52 | */ |
||
53 | public static function build(string $domainName, string $uuid): self |
||
54 | { |
||
55 | return new self(new Name($domainName), new Uuid($uuid)); |
||
56 | } |
||
57 | |||
58 | public function getValue(): string |
||
59 | { |
||
60 | return sprintf('%s:%s', $this->name->getValue(), $this->uuid->getValue()); |
||
61 | } |
||
62 | |||
63 | public function getName(): Name |
||
66 | } |
||
67 | |||
68 | public function getUuid(): Uuid |
||
71 | } |
||
72 | } |
||
73 |