Complex classes like Enumerator often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Enumerator, and based on these observations, apply Extract Interface, too.
| 1 | <?php | ||
| 8 | class Enumerator | ||
| 9 | { | ||
| 10 | use SplitPathTrait; | ||
| 11 | use ValueTrait; | ||
| 12 | |||
| 13 | /** | ||
| 14 | * Return the first element in an array passing a given truth test. | ||
| 15 | * | ||
| 16 | * @param array $array | ||
| 17 | * @param callable $callback | ||
| 18 | * @param mixed $default | ||
| 19 | * | ||
| 20 | * @return mixed | ||
| 21 | */ | ||
| 22 | public function first($array, callable $callback, $default = null) | ||
| 32 | |||
| 33 | /** | ||
| 34 | * Return the last element in an array passing a given truth test. | ||
| 35 | * | ||
| 36 | * @param array $array | ||
| 37 | * @param callable $callback | ||
| 38 | * @param mixed $default | ||
| 39 | * | ||
| 40 | * @return mixed | ||
| 41 | */ | ||
| 42 | public function last($array, callable $callback, $default = null) | ||
| 46 | |||
| 47 | /** | ||
| 48 | * Get a subset of the items from the given array. | ||
| 49 | * | ||
| 50 | * @param string[] $array | ||
| 51 | * @param string[] $keys | ||
| 52 | * | ||
| 53 | * @return string[] | ||
| 54 | */ | ||
| 55 | public function only($array, $keys) | ||
| 59 | |||
| 60 | /** | ||
| 61 | * Get a value from the array, and remove it. | ||
| 62 | * | ||
| 63 | * @param array $array | ||
| 64 | * @param string $key | ||
| 65 | * @param string|null $default | ||
| 66 | * | ||
| 67 | * @return mixed | ||
| 68 | */ | ||
| 69 | public function pull(array &$array, $key, $default = null) | ||
| 77 | |||
| 78 | /** | ||
| 79 | * Pluck an array of values from an array. | ||
| 80 | * | ||
| 81 | * @param array|\ArrayAccess $array | ||
| 82 | * @param string $value | ||
| 83 | * @param string|null $key | ||
| 84 | * | ||
| 85 | * @return array | ||
| 86 | */ | ||
| 87 | public function pluck(array $array, $value, $key = null) | ||
| 108 | |||
| 109 | /** | ||
| 110 | * Filter the array using the given Closure. | ||
| 111 | * | ||
| 112 | * @param array $array | ||
| 113 | * @param callable $callback | ||
| 114 | * | ||
| 115 | * @return array | ||
| 116 | */ | ||
| 117 | public function where(array $array, callable $callback) | ||
| 129 | |||
| 130 | /** | ||
| 131 | * Get an item from an array or object using "dot" notation. | ||
| 132 | * | ||
| 133 | * @param mixed $target | ||
| 134 | * @param string|array $key | ||
| 135 | * @param string $default | ||
| 136 | * | ||
| 137 | * @return mixed | ||
| 138 | */ | ||
| 139 | public function dataGet($target, $key, $default = null) | ||
| 183 | |||
| 184 | /** | ||
| 185 | * Push an item onto the beginning of an array. | ||
| 186 | * | ||
| 187 | * @param array $array | ||
| 188 | * @param mixed $value | ||
| 189 | * @param mixed $key | ||
| 190 | * | ||
| 191 | * @return array | ||
| 192 | */ | ||
| 193 | public function prepend(array $array, $value, $key = null) | ||
| 203 | |||
| 204 | /** | ||
| 205 | * Collapse an array of arrays into a single array. | ||
| 206 | * | ||
| 207 | * @param array $array | ||
| 208 | * | ||
| 209 | * @return array | ||
| 210 | */ | ||
| 211 | public function collapse(array $array) | ||
| 225 | |||
| 226 | /** | ||
| 227 | * Replace a given pattern with each value in the array in sequentially. | ||
| 228 | * | ||
| 229 | * @param string $pattern | ||
| 230 | * @param array $replacements | ||
| 231 | * @param string $subject | ||
| 232 | * | ||
| 233 | * @return string | ||
| 234 | */ | ||
| 235 | public function pregReplaceSub($pattern, &$replacements, $subject) | ||
| 241 | |||
| 242 | /** | ||
| 243 | * A shorter way to run a match on the array's keys rather than the values. | ||
| 244 | * | ||
| 245 | * @param string $pattern | ||
| 246 | * @param array $input | ||
| 247 | * @param int $flags | ||
| 248 | * | ||
| 249 | * @return array | ||
| 250 | */ | ||
| 251 | public function pregGrepKeys($pattern, array $input, $flags = 0) | ||
| 255 | |||
| 256 | /** | ||
| 257 | * Index the array by array of keys. | ||
| 258 | * | ||
| 259 | * @param array $data | ||
| 260 | * @param array $keys | ||
| 261 | * @param bool|true $unique | ||
| 262 | * | ||
| 263 | * @return array | ||
| 264 | */ | ||
| 265 | public function getIndexedByKeys(array $data, array $keys, $unique = true) | ||
| 275 | |||
| 276 | /** | ||
| 277 | * Converts array of arrays to one-dimensional array, where key is $keyName and value is $valueName. | ||
| 278 | * | ||
| 279 | * @param array $array | ||
| 280 | * @param string $keyName | ||
| 281 | * @param string|array $valueName | ||
| 282 | * | ||
| 283 | * @return array | ||
| 284 | */ | ||
| 285 | public function getIndexedValues(array $array, $keyName, $valueName) | ||
| 289 | |||
| 290 | /** | ||
| 291 | * @param array $result | ||
| 292 | * @param array $toSave | ||
| 293 | * @param array $keys | ||
| 294 | * @param bool|true $unique | ||
| 295 | */ | ||
| 296 | protected function indexByKeys(array &$result, array $toSave, array $keys, $unique = true) | ||
| 312 | |||
| 313 | /** | ||
| 314 | * Explode the "value" and "key" arguments passed to "pluck". | ||
| 315 | * | ||
| 316 | * @param string $value | ||
| 317 | * @param string|null $key | ||
| 318 | * | ||
| 319 | * @return array | ||
| 320 | */ | ||
| 321 | protected function explodePluckParameters($value, $key) | ||
| 329 | } | ||
| 330 | 
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.