Completed
Pull Request — master (#155)
by
unknown
01:37
created

AfterMacro   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A after() 0 20 3
1
<?php
2
3
namespace Spatie\CollectionMacros\MacroClasses;
4
5
class AfterMacro
6
{
7
    /**
8
     * Get the next item from the collection.
9
     *
10
     * @return \Closure
11
     */
12
    public function after()
13
    {
14
        return function ($currentItem, $fallback = null) {
15
            $currentKey = $this->search($currentItem, true);
0 ignored issues
show
Bug introduced by
The method search() does not seem to exist on object<Spatie\Collection...acroClasses\AfterMacro>.

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.

Loading history...
16
17
            if ($currentKey === false) {
18
                return $fallback;
19
            }
20
21
            $currentOffset = $this->keys()->search($currentKey, true);
0 ignored issues
show
Bug introduced by
The method keys() does not seem to exist on object<Spatie\Collection...acroClasses\AfterMacro>.

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.

Loading history...
22
23
            $next = $this->slice($currentOffset, 2);
0 ignored issues
show
Bug introduced by
The method slice() does not seem to exist on object<Spatie\Collection...acroClasses\AfterMacro>.

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.

Loading history...
24
25
            if ($next->count() < 2) {
26
                return $fallback;
27
            }
28
29
            return $next->last();
30
        };
31
    }
32
}
33