ContainerSingleton::getInstance()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\Compat;
6
7
use SimpleSAML\Assert\Assert;
8
9
class ContainerSingleton
10
{
11
    /** @var \SimpleSAML\SAML2\Compat\AbstractContainer */
12
    protected static AbstractContainer $container;
13
14
15
    /**
16
     * @return \SimpleSAML\SAML2\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\SAML2\Compat\AbstractContainer $container
29
     */
30
    public static function setContainer(AbstractContainer $container): void
31
    {
32
        self::$container = $container;
33
    }
34
}
35