| Total Complexity | 5 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class ArrayHelper |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Проверка, есть ли в массиве заданное значение |
||
| 12 | * |
||
| 13 | * @param string $value |
||
| 14 | * @param array $stack |
||
| 15 | * @return void |
||
| 16 | * @throws SDKException |
||
| 17 | */ |
||
| 18 | public static function checkValueWithStack(string $value, array $stack): void |
||
| 19 | { |
||
| 20 | if (!in_array($value, $stack)) { |
||
| 21 | throw new SDKException("Value {$value} should be one of " . implode(",", $stack)); |
||
| 22 | } |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Проверка, массива на то содержится ли в нем минимальное количество элементов |
||
| 27 | * |
||
| 28 | * @param array $haystack |
||
| 29 | * @param int $minCount |
||
| 30 | * @return bool |
||
| 31 | */ |
||
| 32 | public static function checkMinValue(array $haystack, int $minCount): bool |
||
| 33 | { |
||
| 34 | return count($haystack) >= $minCount; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Проверка массива на превышение максимального значения |
||
| 39 | * |
||
| 40 | * @param array $haystack |
||
| 41 | * @param int $maxCount |
||
| 42 | * @return bool |
||
| 43 | */ |
||
| 44 | public static function checkMaxValue(array $haystack, int $maxCount): bool |
||
| 47 | } |
||
| 48 | |||
| 49 | public static function assign($value, $defaultValue = []): array |
||
| 54 |