| Total Complexity | 8 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 17 | final class FilterDataValidationHelper |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @param mixed $field |
||
| 21 | */ |
||
| 22 | 182 | public static function assertFieldIsString($field): void |
|
| 23 | { |
||
| 24 | 182 | if (!is_string($field)) { |
|
| 25 | 80 | throw new InvalidArgumentException(sprintf( |
|
| 26 | 80 | 'The field should be string. The %s is received.', |
|
| 27 | 80 | self::getValueType($field), |
|
| 28 | )); |
||
| 29 | } |
||
| 30 | 102 | } |
|
| 31 | |||
| 32 | /** |
||
| 33 | * @param mixed $value |
||
| 34 | */ |
||
| 35 | 73 | public static function assertIsScalar($value): void |
|
| 41 | )); |
||
| 42 | } |
||
| 43 | 45 | } |
|
| 44 | |||
| 45 | /** |
||
| 46 | * @param mixed $filterProcessor |
||
| 47 | */ |
||
| 48 | 23 | public static function assertFilterProcessorIsIterable($filterProcessor): void |
|
| 49 | { |
||
| 50 | 23 | if (!$filterProcessor instanceof IterableProcessorInterface) { |
|
| 51 | 3 | throw new InvalidArgumentException(sprintf( |
|
| 52 | 3 | 'The filter processor should be an object and implement "%s". The %s is received.', |
|
| 53 | 3 | IterableProcessorInterface::class, |
|
| 54 | 3 | self::getValueType($filterProcessor), |
|
| 55 | )); |
||
| 56 | } |
||
| 57 | 20 | } |
|
| 58 | |||
| 59 | /** |
||
| 60 | * @param mixed $value |
||
| 61 | */ |
||
| 62 | 178 | public static function getValueType($value): string |
|
| 65 | } |
||
| 66 | } |
||
| 67 |