| Conditions | 3 |
| Paths | 4 |
| Total Lines | 10 |
| Code Lines | 5 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public static function validate(?string $value, bool $allowNull = false): void |
||
| 17 | { |
||
| 18 | $availableValues = static::getAvailableValues(); |
||
| 19 | |||
| 20 | if ($allowNull) { |
||
| 21 | $availableValues[] = null; |
||
| 22 | } |
||
| 23 | |||
| 24 | if (!in_array($value, $availableValues, true)) { |
||
| 25 | throw new InvalidArgumentException(sprintf('Invalid value "%s". Available values are: %s', $value, implode(', ', $availableValues))); |
||
| 26 | } |
||
| 39 |