We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 18 | class Length extends AbstractRule |
||
| 19 | { |
||
| 20 | public $minValue; |
||
| 21 | public $maxValue; |
||
| 22 | public $inclusive; |
||
| 23 | |||
| 24 | 23 | public function __construct($min = null, $max = null, $inclusive = true) |
|
| 48 | |||
| 49 | 20 | public function validate($input) |
|
| 55 | |||
| 56 | 20 | protected function extractLength($input) |
|
| 57 | { |
||
| 58 | 20 | if (is_string($input)) { |
|
| 59 | 13 | return mb_strlen($input, mb_detect_encoding($input)); |
|
| 60 | } |
||
| 61 | |||
| 62 | 7 | if (is_array($input) || $input instanceof \Countable) { |
|
| 63 | 4 | return count($input); |
|
| 64 | } |
||
| 65 | |||
| 66 | 3 | if (is_object($input)) { |
|
| 67 | 3 | return count(get_object_vars($input)); |
|
| 68 | } |
||
| 69 | |||
| 70 | if (is_int($input)) { |
||
| 71 | return mb_strlen((string) $input); |
||
| 72 | } |
||
| 73 | |||
| 74 | return false; |
||
| 75 | } |
||
| 76 | |||
| 77 | 20 | protected function validateMin($length) |
|
| 89 | |||
| 90 | 17 | protected function validateMax($length) |
|
| 102 | } |
||
| 103 |