Completed
Pull Request — master (#75)
by Vladimir
02:16
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
/**
4
 * @copyright 2018 Vladimir Jimenez
5
 * @license   https://github.com/stakx-io/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx\EventSubscriber;
9
10
use allejo\stakx\Event\PageViewAdded;
11
use allejo\stakx\Server\PageViewRouter;
12
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
13
14
class RouterSubscriber implements EventSubscriberInterface
15
{
16
    private $routerMapping;
17
18
    public function __construct(PageViewRouter $routerMapping)
19
    {
20
        $this->routerMapping = $routerMapping;
21
    }
22
23
    public function registerPageView(PageViewAdded $event)
24
    {
25
        $this->routerMapping->registerPageView($event->getPageView());
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public static function getSubscribedEvents()
32
    {
33
        return [
34
            PageViewAdded::NAME => 'registerPageView',
35
        ];
36
    }
37
}
38