Completed
Push — master ( 5ea094...a8ad24 )
by Dmitry
04:15
created

Event::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Basis;
4
5
use Tarantool\Mapper\Plugins\Spy;
6
7
class Event
8
{
9
    private $dispatcher;
10
11
    public function __construct(Dispatcher $dispatcher)
12
    {
13
        $this->dispatcher = $dispatcher;
14
    }
15
16
    public function fire($event, $context)
17
    {
18
        $this->dispatcher->dispatch('event.fire', [
19
            'event' => $event,
20
            'context' => $context
21
        ]);
22
    }
23
24
    public function subscribe($event, $listener)
25
    {
26
        $this->dispatcher->dispatch('event.subscribe', [
27
            'event' => $event,
28
            'listener' => $listener,
29
        ]);
30
    }
31
32
    public function fireChanges(Spy $spy)
33
    {
34
        if($spy->hasChanges()) {
35
            $this->dispatcher->dispatch('event.changes', $spy->getChanges());
36
        }
37
    }
38
}
39