| Total Complexity | 5 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 5 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 15 | class Uuid extends ValueObject implements Arrayable |
||
| 16 | { |
||
| 17 | use Macroable, Conditionable; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param string|null $uuid |
||
| 21 | * @param string|null $name |
||
| 22 | */ |
||
| 23 | 8 | public function __construct( |
|
| 24 | protected ?string $uuid, |
||
| 25 | protected ?string $name = null, |
||
| 26 | ) { |
||
| 27 | // |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @return string |
||
| 32 | */ |
||
| 33 | 2 | public function name(): string |
|
| 34 | { |
||
| 35 | 2 | return (string) $this->name; |
|
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @return string |
||
| 40 | */ |
||
| 41 | 6 | public function value(): string |
|
| 42 | { |
||
| 43 | 6 | return (string) $this->uuid; |
|
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @return array |
||
| 48 | */ |
||
| 49 | 1 | public function toArray(): array |
|
| 50 | { |
||
| 51 | return [ |
||
|
|
|||
| 52 | 1 | 'name' => $this->name(), |
|
| 53 | 1 | 'value' => $this->value(), |
|
| 54 | ]; |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @return string |
||
| 59 | */ |
||
| 60 | 1 | public function __toString(): string |
|
| 63 | } |
||
| 64 | } |
||
| 65 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: