MappedRegistry::register()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
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