| Total Complexity | 4 |
| Total Lines | 23 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | class StringGuard implements Guard |
||
| 19 | { |
||
| 20 | use ErrorMessagesBase; |
||
| 21 | use StringBase; |
||
| 22 | use SingleInput; |
||
| 23 | |||
| 24 | 12 | public function __construct($input, ?int $default = null) |
|
| 25 | { |
||
| 26 | 12 | $this->input = $input; |
|
| 27 | 12 | $this->value = $default; |
|
| 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 or boolean. |
||
| 33 | 11 | return $this->strict ? \is_string($input) : \is_scalar($input); |
|
|
|
|||
| 34 | } |
||
| 35 | |||
| 36 | 10 | public function value(): ?string |
|
| 41 | } |
||
| 42 | } |
||
| 43 |