Total Complexity | 8 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class Helpers |
||
11 | { |
||
12 | /** |
||
13 | * @param $data |
||
14 | * @return array |
||
15 | */ |
||
16 | public static function clearArray($data) |
||
22 | }); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * @param $array |
||
27 | * @param $keys |
||
28 | * @throws LogicException |
||
29 | */ |
||
30 | public static function validateArray($array, $keys) |
||
31 | { |
||
32 | foreach ($keys as $key) { |
||
33 | if (array_has($array, $key) == false) { |
||
|
|||
34 | throw LogicException::requiredFieldDoesntExist($key); |
||
35 | } |
||
36 | } |
||
37 | } |
||
38 | |||
39 | |||
40 | /** |
||
41 | * Get all of the given array except for a specified array of items. |
||
42 | * |
||
43 | * @param array $array |
||
44 | * @param array|string $keys |
||
45 | * @return array |
||
46 | */ |
||
47 | public static function array_except($array, $keys) |
||
48 | { |
||
49 | return array_diff_key($array, array_flip((array)$keys)); |
||
50 | } |
||
51 | |||
52 | public static function replaceArrayKeys($array, $search, $replace) |
||
61 | } |
||
62 | |||
63 | } |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.