Passed
Push — master ( 6f214c...ffcc9b )
by WEBEWEB
13:06
created

CompatibilityService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 7
c 0
b 0
f 0
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSession() 0 7 2
A __construct() 0 2 1
1
<?php
2
3
/*
4
 * This file is part of the core-bundle package.
5
 *
6
 * (c) 2023 WEBEWEB
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 WBW\Bundle\CoreBundle\Service;
13
14
use Psr\Container\ContainerInterface;
15
use Symfony\Component\HttpFoundation\Session\SessionInterface;
16
use Symfony\Component\HttpKernel\Kernel;
17
use WBW\Bundle\CoreBundle\DependencyInjection\Container\ContainerTrait;
18
19
/**
20
 * Compatibility service.
21
 *
22
 * @author webeweb <https://github.com/webeweb>
23
 * @package WBW\Bundle\CoreBundle\Service
24
 */
25
class CompatibilityService implements CompatibilityServiceInterface {
26
27
    use ContainerTrait;
28
29
    /**
30
     * Service name.
31
     *
32
     * @var string
33
     */
34
    const SERVICE_NAME = "wbw.core.service.compatibility";
35
36
    /**
37
     * Constructor.
38
     *
39
     * @param ContainerInterface $container The container.
40
     */
41
    public function __construct(ContainerInterface $container) {
42
        $this->setContainer($container);
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function getSession(): ?SessionInterface {
49
50
        if (6 <= Kernel::MAJOR_VERSION) {
51
            return $this->getContainer()->get("request_stack")->getSession();
52
        }
53
54
        return $this->getContainer()->get("session");
55
    }
56
}
57