| Total Complexity | 6 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | class StringableGuard implements Guard |
||
| 19 | { |
||
| 20 | use ErrorMessagesBase; |
||
| 21 | use StringBase; |
||
| 22 | use SingleInput; |
||
| 23 | |||
| 24 | 12 | public function __construct($input, ?int $default = null) |
|
| 28 | 12 | } |
|
| 29 | |||
| 30 | 11 | protected function validationShortCircuit($input): bool |
|
| 31 | { |
||
| 32 | // The is_scalar is a short circuit for anything not a integer, float, string, boolean. |
||
| 33 | 11 | if ($this->strict ? \is_string($input) : \is_scalar($input)) { |
|
|
|
|||
| 34 | 6 | return true; |
|
| 35 | } |
||
| 36 | |||
| 37 | 5 | return (\is_object($input) && method_exists($input, '__toString')); |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @return null|string|object |
||
| 42 | */ |
||
| 43 | 10 | public function value() |
|
| 48 | } |
||
| 49 | } |
||
| 50 |