RequestListener   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 40
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
B onKernelRequest() 0 15 5
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
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 ONGR\SettingsBundle\EventListener;
13
14
use ONGR\CookiesBundle\Cookie\Model\GenericCookie;
15
use ONGR\SettingsBundle\Service\SettingsManager;
16
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
17
18
class RequestListener
19
{
20
    /**
21
     * @var GenericCookie
22
     */
23
    private $profileCookie;
24
25
    /**
26
     * @var GenericCookie
27
     */
28
    private $experimentCookie;
29
30
    /**
31
     * @var SettingsManager
32
     */
33
    private $settingsManager;
34
35
    public function __construct($profileCookie, $experimentCookie, $settingsManager)
36
    {
37
        $this->profileCookie = $profileCookie;
38
        $this->experimentCookie = $experimentCookie;
39
        $this->settingsManager = $settingsManager;
40
    }
41
42
    public function onKernelRequest(GetResponseEvent $event)
43
    {
44
        if (!$event->isMasterRequest()) {
45
            return;
46
        }
47
48
        $profileCookie = $this->profileCookie->getValue() ? $this->profileCookie->getValue() : [];
49
        $expCookie = $this->experimentCookie->getValue() ? $this->experimentCookie->getValue() : [];
50
51
        $profiles = array_merge($profileCookie, $expCookie);
52
53
        if (is_array($profiles)) {
54
            $this->settingsManager->appendActiveProfilesList($profiles);
55
        }
56
    }
57
}
58