Issues (7)

Classes/Container/SingletonContainer.php (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace DMK\MKSamlAuth\Container;
6
7
use TYPO3\CMS\Core\SingletonInterface;
8
use TYPO3\CMS\Extbase\Object\Container\Container;
9
10
class SingletonContainer implements SingletonInterface
11
{
12
    /**
13
     * @var Container
14
     */
15
    private $container;
16
17
    /**
18
     * @var []
0 ignored issues
show
Documentation Bug introduced by
The doc comment [] at position 0 could not be parsed: Unknown type name '[' at position 0 in [].
Loading history...
19
     */
20
    private $instances;
21
22
    public function __construct(Container $container)
23
    {
24
        $this->container = $container;
25
        $this->instances = [];
26
    }
27
28
    public function getInstance(string $className, array $givenConstructorArguments = [])
29
    {
30
        if (isset($this->instances[$className])) {
31
            return $this->instances[$className];
32
        }
33
34
        return $this->instances[$className] = $this->container->getInstance($className, $givenConstructorArguments);
35
    }
36
}
37