CakeEvmProxy::attach()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 1
Metric Value
cc 1
eloc 5
c 2
b 1
f 1
nc 1
nop 3
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 1
rs 9.4285
1
<?php
2
namespace Penny\Event;
3
4
use Cake\Event\Event as BaseCakeEvent;
5
use Cake\Event\EventManager;
6
7
class CakeEvmProxy implements EventManagerInterface
8
{
9
    /**
10
     * @var EventManager
11
     */
12
    private $eventManager;
13
14
    /**
15
     * Proxy EventManager
16
     */
17 1
    public function __construct()
18
    {
19 1
        $this->eventManager = new EventManager();
20 1
    }
21
22
    /**
23
     * {@inheritDoc}
24
     */
25 1
    public function trigger(EventInterface $event)
26
    {
27 1
        if ($event instanceof BaseCakeEvent) {
28 1
            $this->eventManager->dispatch($event);
29 1
        }
30 1
        return $this;
31
    }
32
33
    /**
34
     * {@inheritDoc}
35
     */
36 1
    public function attach($eventName, callable $listener, $priority = 1)
37
    {
38 1
        $options = [];
39 1
        $options['priority'] = $priority;
40 1
        $this->eventManager->on($eventName, $options, $listener);
41 1
        return $this;
42
    }
43
}
44