| Total Complexity | 4 |
| Total Lines | 26 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | class Required implements Type |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @var Type $type |
||
| 20 | */ |
||
| 21 | private $type; |
||
| 22 | /** |
||
| 23 | * Required constructor. |
||
| 24 | * @param Type $type |
||
| 25 | * @throws EmptyRequiredValue |
||
| 26 | */ |
||
| 27 | public function __construct(Type $type) |
||
| 28 | { |
||
| 29 | if (empty($type->getValue())) |
||
| 30 | throw new EmptyRequiredValue('The required type '. get_class($type) . ' cannot have an empty value'); |
||
| 31 | |||
| 32 | $this->type = $type; |
||
| 33 | } |
||
| 34 | |||
| 35 | public function __toString(): string |
||
| 37 | } |
||
|
|
|||
| 38 | |||
| 39 | public function getValue() |
||
| 42 | } |
||
| 43 | } |
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: