1 | <?php |
||
6 | class Enumerator |
||
7 | { |
||
8 | use ValueTrait; |
||
9 | |||
10 | /** |
||
11 | * Get a random element from the array supplied. |
||
12 | * |
||
13 | * @param array $array the source array |
||
14 | * |
||
15 | * @return mixed |
||
16 | */ |
||
17 | public function random(array $array) |
||
27 | |||
28 | /** |
||
29 | * Get a subset of the items from the given array. |
||
30 | * |
||
31 | * @param string[] $array |
||
32 | * @param string[] $keys |
||
33 | * |
||
34 | * @return string[] |
||
35 | */ |
||
36 | public function only(array $array, $keys) |
||
40 | |||
41 | /** |
||
42 | * Determines if an array is associative. |
||
43 | * |
||
44 | * @param array $array |
||
45 | * |
||
46 | * @return bool |
||
47 | */ |
||
48 | public function isAssoc(array $array) |
||
56 | |||
57 | /** |
||
58 | * Split an array in the given amount of pieces. |
||
59 | * |
||
60 | * @param array $array |
||
61 | * @param int $numberOfPieces |
||
62 | * @param bool $preserveKeys |
||
63 | * |
||
64 | * @return array |
||
65 | */ |
||
66 | public function split(array $array, $numberOfPieces = 2, $preserveKeys = false) |
||
76 | |||
77 | /** |
||
78 | * Check if an array has a numeric index. |
||
79 | * |
||
80 | * @param array $array |
||
81 | * |
||
82 | * @return bool |
||
83 | */ |
||
84 | public function isIndexed(array $array) |
||
92 | |||
93 | /** |
||
94 | * Push an item onto the beginning of an array. |
||
95 | * |
||
96 | * @param array $array |
||
97 | * @param mixed $value |
||
98 | * @param mixed $key |
||
99 | * |
||
100 | * @return array |
||
101 | */ |
||
102 | public function prepend(array $array, $value, $key = null) |
||
112 | |||
113 | /** |
||
114 | * Replace a given pattern with each value in the array in sequentially. |
||
115 | * |
||
116 | * @param string $pattern |
||
117 | * @param array $replacements |
||
118 | * @param string $subject |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | public function pregReplaceSub($pattern, &$replacements, $subject) |
||
128 | |||
129 | /** |
||
130 | * A shorter way to run a match on the array's keys rather than the values. |
||
131 | * |
||
132 | * @param string $pattern |
||
133 | * @param array $input |
||
134 | * @param int $flags |
||
135 | * |
||
136 | * @return array |
||
137 | */ |
||
138 | public function pregGrepKeys($pattern, array $input, $flags = 0) |
||
142 | |||
143 | /** |
||
144 | * Explode the "value" and "key" arguments passed to "pluck". |
||
145 | * |
||
146 | * @param string $value |
||
147 | * @param string|null $key |
||
148 | * |
||
149 | * @return array[] |
||
150 | */ |
||
151 | protected function explodePluckParameters($value, $key) |
||
159 | } |
||
160 |