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