EventManager::fire()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 7
ccs 0
cts 5
cp 0
rs 9.4285
c 1
b 0
f 1
cc 2
eloc 3
nc 2
nop 2
crap 6
1
<?php namespace Packedge\Workbench\Foundation;
2
3
class EventManager
4
{
5
    protected $events = [];
6
7
    public function listen($name, $className)
8
    {
9
        if(!is_string($className)) throw new InvalidArgumentException;
10
        $this->events[$name][] = new $className($this);
11
    }
12
13
    public function fire($name, $data)
14
    {
15
        foreach($this->events[$name] as $event => $object)
16
        {
17
            $object->{'handle'}($data);
18
        }
19
    }
20
}