FactoryInstances   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 8
c 1
b 0
f 0
dl 0
loc 28
ccs 8
cts 8
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A init() 0 3 1
A getInstance() 0 6 2
A __clone() 0 2 1
1
<?php
2
3
namespace kalanis\kw_storage\Access;
4
5
6
use kalanis\kw_storage\Interfaces;
7
8
9
/**
10
 * Class FactoryInstances
11
 * @package kalanis\kw_storage\Access
12
 * Factory instances for getting each wanted storage
13
 */
14
class FactoryInstances
15
{
16
    protected static ?FactoryInstances $instance = null;
17
    protected Factory $factory;
18
19 1
    public static function init(?Interfaces\IStTranslations $lang = null): void
20
    {
21 1
        static::$instance = new self($lang);
22
    }
23
24 1
    public static function getInstance(?Interfaces\IStTranslations $lang = null): Factory
25
    {
26 1
        if (empty(static::$instance)) {
27 1
            static::$instance = new self($lang);
28
        }
29 1
        return static::$instance->factory;
30
    }
31
32 1
    protected function __construct(?Interfaces\IStTranslations $lang = null)
33
    {
34 1
        $this->factory = new Factory($lang);
35
    }
36
37
    /**
38
     * @codeCoverageIgnore singleton
39
     */
40
    private function __clone()
41
    {
42
        // cannot run
43
    }
44
}
45