Completed
Push — master ( 192dbb...5ea094 )
by Dmitry
04:40
created

Event::fireDataChange()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
crap 6
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 fireDataChange(Spy $spy)
33
    {
34
        if($spy->hasChanges()) {
35
            $this->dispatcher->dispatch('event.changes', $spy->getChanges());
36
        }
37
    }
38
}
39