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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 40
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A groupMap() 0 16 3
A sortListeners() 0 10 1
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
}