Conditions | 5 |
Paths | 1 |
Total Lines | 40 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
17 | public function __invoke() { |
||
18 | return function ($callback, bool $preserveKeys = false): Collection { |
||
19 | if ($this->isEmpty()) { |
||
|
|||
20 | return new static(); |
||
21 | } |
||
22 | |||
23 | if (! $preserveKeys) { |
||
24 | $sliced = new static([ |
||
25 | new static([$this->first()]), |
||
26 | ]); |
||
27 | |||
28 | return $this->eachCons(2)->reduce(function ($sliced, $previousAndCurrent) use ($callback) { |
||
29 | list($previousItem, $item) = $previousAndCurrent; |
||
30 | |||
31 | $callback($item, $previousItem) |
||
32 | ? $sliced->push(new static([$item])) |
||
33 | : $sliced->last()->push($item); |
||
34 | |||
35 | return $sliced; |
||
36 | }, $sliced); |
||
37 | } |
||
38 | |||
39 | $sliced = new static([$this->take(1)]); |
||
40 | |||
41 | return $this->eachCons(2, $preserveKeys)->reduce(function ($sliced, $previousAndCurrent) use ($callback) { |
||
42 | $previousItem = $previousAndCurrent->take(1); |
||
43 | $item = $previousAndCurrent->take(-1); |
||
44 | |||
45 | $itemKey = $item->keys()->first(); |
||
46 | $valuesItem = $item->first(); |
||
47 | $valuesPreviousItem = $previousItem->first(); |
||
48 | |||
49 | $callback($valuesItem, $valuesPreviousItem) |
||
50 | ? $sliced->push($item) |
||
51 | : $sliced->last()->put($itemKey, $valuesItem); |
||
52 | |||
53 | return $sliced; |
||
54 | }, $sliced); |
||
55 | }; |
||
56 | } |
||
57 | } |
||
58 |
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.