CakeEvmProxy   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A trigger() 0 7 2
A attach() 0 7 1
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