SystemContainer   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
eloc 12
c 2
b 0
f 0
dl 0
loc 43
rs 10
ccs 0
cts 29
cp 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getLogger() 0 3 1
A getTimeProvider() 0 3 1
A getSession() 0 10 2
A getEventDispatcher() 0 3 1
A getRequest() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DMK\MKSamlAuth\Container;
6
7
use DMK\MKSamlAuth\Session\PhpSession;
8
use LightSaml\Build\Container\SystemContainerInterface;
9
use LightSaml\Provider\TimeProvider\SystemTimeProvider;
10
use LightSaml\Provider\TimeProvider\TimeProviderInterface;
11
use Psr\Log\LoggerInterface;
12
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
13
use Symfony\Component\HttpFoundation\Request;
14
use Symfony\Component\HttpFoundation\Session\Session;
15
use TYPO3\CMS\Core\Log\LogManager;
16
use TYPO3\CMS\Core\SingletonInterface;
17
use TYPO3\CMS\Core\Utility\GeneralUtility;
18
19
class SystemContainer implements SystemContainerInterface, SingletonInterface
20
{
21
    /**
22
     * @var SingletonContainer
23
     */
24
    private $container;
25
26
    public function __construct(SingletonContainer $container)
27
    {
28
        $this->container = $container;
29
    }
30
31
    public function getRequest(): Request
32
    {
33
        return Request::createFromGlobals();
34
    }
35
36
    public function getSession(): Session
37
    {
38
        static $session;
39
40
        if ($session) {
41
            return $session;
42
        }
43
44
        return $session = new Session(
45
            $this->container->getInstance(PhpSession::class)
46
        );
47
    }
48
49
    public function getTimeProvider(): TimeProviderInterface
50
    {
51
        return $this->container->getInstance(SystemTimeProvider::class);
52
    }
53
54
    public function getEventDispatcher(): EventDispatcherInterface
55
    {
56
        return $this->container->getInstance(EventDispatcherInterface::class);
57
    }
58
59
    public function getLogger(): LoggerInterface
60
    {
61
        return GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
62
    }
63
}
64