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