Completed
Pull Request — master (#75)
by Vladimir
02:18
created

RouterSubscriber   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 24
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A registerPageView() 0 4 1
A getSubscribedEvents() 0 6 1
1
<?php
2
3
namespace allejo\stakx\EventSubscriber;
4
5
use allejo\stakx\Event\PageViewAdded;
6
use allejo\stakx\Server\PageViewRouter;
7
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8
9
class RouterSubscriber implements EventSubscriberInterface
10
{
11
    private $routerMapping;
12
13
    public function __construct(PageViewRouter $routerMapping)
14
    {
15
        $this->routerMapping = $routerMapping;
16
    }
17
18
    public function registerPageView(PageViewAdded $event)
19
    {
20
        $this->routerMapping->registerPageView($event->getPageView());
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public static function getSubscribedEvents()
27
    {
28
        return [
29
            PageViewAdded::NAME => 'registerPageView'
30
        ];
31
    }
32
}
33