ContainerSingleton   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getInstance() 0 4 1
A setContainer() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML11\Compat;
6
7
use SimpleSAML\Assert\Assert;
8
9
class ContainerSingleton
10
{
11
    /** @var \SimpleSAML\SAML11\Compat\AbstractContainer */
12
    protected static AbstractContainer $container;
13
14
15
    /**
16
     * @return \SimpleSAML\SAML11\Compat\AbstractContainer
17
     */
18
    public static function getInstance(): AbstractContainer
19
    {
20
        Assert::notNull(self::$container, 'No container set.');
21
        return self::$container;
22
    }
23
24
25
    /**
26
     * Set a container to use.
27
     *
28
     * @param \SimpleSAML\SAML11\Compat\AbstractContainer $container
29
     */
30
    public static function setContainer(AbstractContainer $container): void
31
    {
32
        self::$container = $container;
33
    }
34
}
35