| Total Complexity | 9 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | final class Name |
||
| 13 | { |
||
| 14 | private $value; |
||
| 15 | |||
| 16 | 220 | public function __construct(string $value) |
|
| 25 | 219 | } |
|
| 26 | |||
| 27 | 8 | public function add(self $name): self |
|
| 28 | { |
||
| 29 | 8 | return new self($this->value.'.'.$name); |
|
| 30 | } |
||
| 31 | |||
| 32 | 48 | public function root(): self |
|
| 33 | { |
||
| 34 | 48 | $namespace = $this->value->split('.'); |
|
| 35 | |||
| 36 | 48 | if ($namespace->size() === 1) { |
|
| 37 | 22 | throw new NameNotNamespaced((string) $this->value); |
|
| 38 | } |
||
| 39 | |||
| 40 | 32 | return new self((string) $namespace->first()); |
|
| 41 | } |
||
| 42 | |||
| 43 | 28 | public function withoutRoot(): self |
|
| 52 | } |
||
| 53 | |||
| 54 | 6 | public function equals(self $other): bool |
|
| 55 | { |
||
| 56 | 6 | return (string) $this === (string) $other; |
|
| 57 | } |
||
| 58 | |||
| 59 | 201 | public function __toString(): string |
|
| 62 | } |
||
| 63 | } |
||
| 64 |