MappedRegistry::find()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php namespace Cairns\Radiate\Registry;
2
3
final class MappedRegistry implements Registry
4
{
5
    private $listeners = [];
6
7 1
    public function register($event, $listener)
8
    {
9 1
        $this->listeners[$event][] = $listener;
10 1
    }
11
12 2
    public function find($event)
13
    {
14 2
        $eventClassName = get_class($event);
15
16 2
        if (! array_key_exists($eventClassName, $this->listeners)) {
17 1
            return [];
18
        }
19
20 1
        return $this->listeners[$eventClassName];
21
    }
22
}
23