CollectorSubscriber   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 53
ccs 22
cts 22
cp 1
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getSubscribedEvents() 0 7 1
A onTcContainer() 0 9 1
A onTcEvent() 0 8 1
1
<?php
2
3
/**
4
* This file is part of the Meup TagCommander Bundle.
5
*
6
* (c) 1001pharmacies <http://github.com/1001pharmacies/tagcommander-bundle>
7
*
8
* For the full copyright and license information, please view the LICENSE
9
* file that was distributed with this source code.
10
*/
11
12
namespace Meup\Bundle\TagcommanderBundle\EventDispatcher\Subscriber;
13
14
use Meup\Bundle\TagcommanderBundle\DataCollector\DataLayerCollector;
15
use Meup\Bundle\TagcommanderBundle\EventDispatcher\Event\Track;
16
use Meup\Bundle\TagcommanderBundle\EventDispatcher\Event\DeployContainer;
17
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
18
19
/**
20
 *
21
 */
22
class CollectorSubscriber implements EventSubscriberInterface
23
{
24
    /**
25
     * @var DataLayerCollector
26
     */
27
    protected $collector;
28
29
    /**
30
     * @param DataLayerCollector $collector
31
     */
32 1
    public function __construct(DataLayerCollector $collector)
33
    {
34 1
        $this->collector = $collector;
35 1
    }
36
37
    /**
38
     * @return array<string,array<string|integer>>
39
     */
40 1
    public static function getSubscribedEvents()
41
    {
42
        return array(
43 1
            'tc_container' => array('onTcContainer', 0),
44 1
            'tc_event'     => array('onTcEvent', 0),
45 1
        );
46
    }
47
48
    /**
49
     * @param DeployContainer $event
50
     * @return void
51
     */
52 1
    public function onTcContainer(DeployContainer $event)
53
    {
54 1
        $this->collector->collectContainer(
55 1
            $event->getContainerName(),
56 1
            $event->getContainerScript(),
57 1
            $event->getContainerVersion(),
58 1
            $event->getContainerAlternative()
59 1
        );
60 1
    }
61
62
    /**
63
     * @param Track $event
64
     * @return void
65
     */
66 1
    public function onTcEvent(Track $event)
67
    {
68 1
        $this->collector->collectEvent(
69 1
            $event->getTrackerName(),
70 1
            $event->getEventName(),
71 1
            $event->getValues()
72 1
        );
73 1
    }
74
}
75