EventManager   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 18
ccs 0
cts 9
cp 0
rs 10
c 1
b 0
f 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A listen() 0 5 2
A fire() 0 7 2
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
}