Passed
Push — master ( 106687...22ee89 )
by WEBEWEB
02:59
created

SymfonyBCService::getSession()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
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
 * Symfony backward compatibility service.
21
 *
22
 * @author webeweb <https://github.com/webeweb>
23
 * @package WBW\Bundle\CoreBundle\Service
24
 */
25
class SymfonyBCService implements SymfonyBCServiceInterface {
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 (50300 <= Kernel::VERSION_ID) {
51
            return $this->getContainer()->get("request_stack")->getSession();
52
        }
53
54
        return $this->getContainer()->get("session");
55
    }
56
}
57