| Total Complexity | 5 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | class IterableStringableGuard implements Guard |
||
| 20 | { |
||
| 21 | use ErrorMessagesBase; |
||
| 22 | use SingleIterableInput; |
||
| 23 | use StringBase { |
||
| 24 | // Use the iterable's validation as the primary validation logic and rename the string validation method. |
||
| 25 | SingleIterableInput::validation insteadof StringBase; |
||
| 26 | StringBase::validation as stringValidation; |
||
| 27 | } |
||
| 28 | |||
| 29 | 6 | public function __construct($input, ?iterable $default = null) |
|
| 33 | 6 | } |
|
| 34 | |||
| 35 | 4 | protected function validationShortCircuit($input): bool |
|
| 36 | { |
||
| 37 | // Short circuit for anything not a integer, float, string, boolean, or object with a __toString method. |
||
| 38 | 4 | return is_scalar($input) || (\is_object($input) && method_exists($input, '__toString')); |
|
| 39 | } |
||
| 40 | |||
| 41 | 4 | protected function validateIterableElement($element, &$value): bool |
|
| 44 | } |
||
| 45 | } |
||
| 46 |