GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( d045d2...d7dabc )
by Constantin
02:43
created

GrouperByEvent::groupMap()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 4
nop 1
crap 3
1
<?php
2
3
4
namespace Gica\CodeAnalysis\MethodListenerDiscovery\MapGrouper;
5
6
7
use Gica\CodeAnalysis\MethodListenerDiscovery\ClassSorter\ByConstructorDependencySorter;
8
use Gica\CodeAnalysis\MethodListenerDiscovery\ListenerMethod;
9
10
class GrouperByEvent
11
{
12
13
    /**
14
     * @param ListenerMethod[] $map
15
     * @return array
16
     */
17 1
    public function groupMap(array $map)
18
    {
19 1
        $groupedByEvent = [];
20
21 1
        foreach ($map as $listenerMethod) {
22 1
            $groupedByEvent[$listenerMethod->getEventClassName()][] = $listenerMethod;
23
        }
24
25 1
        $sorted = [];
26
27 1
        foreach ($groupedByEvent as $eventClass => $listeners) {
28 1
            $sorted[$eventClass] = $this->sortListeners($listeners);
29
        }
30
31 1
        return $sorted;
32
    }
33
34
    /**
35
     * @param ListenerMethod[] $listeners
36
     * @return ListenerMethod[]
37
     */
38 1
    private function sortListeners($listeners)
39
    {
40 1
        $classSorter = new ByConstructorDependencySorter();
41
42 1
        usort($listeners, function (ListenerMethod $a, ListenerMethod $b) use ($classSorter) {
43
            return $classSorter->__invoke($a->getClass(), $b->getClass());
44 1
        });
45
46 1
        return $listeners;
47
    }
48
49
}