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

Event   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 32
ccs 0
cts 24
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fire() 0 7 1
A subscribe() 0 7 1
A fireDataChange() 0 6 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 fireDataChange(Spy $spy)
33
    {
34
        if($spy->hasChanges()) {
35
            $this->dispatcher->dispatch('event.changes', $spy->getChanges());
36
        }
37
    }
38
}
39