Total Complexity | 11 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class Collection |
||
10 | { |
||
11 | protected const ERROR_INVALID_ATTRIBUTES = 'invalid attributes (array of string[] and null items)'; |
||
12 | |||
13 | /** |
||
14 | * @param array $items |
||
15 | * @param string $className |
||
16 | * |
||
17 | * @return bool |
||
18 | */ |
||
19 | public static function allInstanceOf(array $items, string $className): bool |
||
20 | { |
||
21 | if (empty($className)) { |
||
22 | return true; |
||
23 | } |
||
24 | |||
25 | foreach ($items as $item) { |
||
26 | if (!($item instanceof $className)) { |
||
27 | return false; |
||
28 | } |
||
29 | } |
||
30 | |||
31 | return true; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @param array $items |
||
36 | * |
||
37 | * @return bool |
||
38 | */ |
||
39 | public static function allNodes(array $items): bool |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @param string[] $items |
||
52 | * |
||
53 | * @return bool |
||
54 | */ |
||
55 | public static function allStrings(array $items): bool |
||
66 |