Helper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 36
ccs 11
cts 11
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A initStorage() 0 3 1
A getMultiStorage() 0 3 1
A initFactory() 0 5 1
A getStorage() 0 3 1
1
<?php
2
3
namespace kalanis\kw_storage;
4
5
6
use kalanis\kw_storage\Interfaces\IStorage;
7
use kalanis\kw_storage\Interfaces\IStTranslations;
8
9
10
/**
11
 * Class Helper
12
 * @package kalanis\kw_storage
13
 * Create cache with already known settings
14
 */
15
class Helper
16
{
17 1
    public static function initStorage(?IStTranslations $lang = null): Storage
18
    {
19 1
        return new Storage(static::initFactory($lang), $lang);
20
    }
21
22 1
    public static function initFactory(?IStTranslations $lang = null): Storage\Factory
23
    {
24 1
        return new Storage\Factory(
25 1
            new Storage\Key\Factory(),
26 1
            new Storage\Target\Factory($lang)
27 1
        );
28
    }
29
30
    /**
31
     * @param array<string|int, string|int|float|object|bool|array<string|int|float|object>>|string|object|int|bool|null $params
32
     * @param IStTranslations|null $lang
33
     * @throws StorageException
34
     * @return IStorage
35
     */
36 1
    public static function getStorage($params, ?IStTranslations $lang = null): IStorage
37
    {
38 1
        return (new Access\Factory($lang))->getStorage($params);
39
    }
40
41
    /**
42
     * @param array<string|int, string|int|float|object|bool|array<string|int|float|object>>|string|object|int|bool|null $params
43
     * @param string|null $alias
44
     * @param IStTranslations|null $lang
45
     * @throws StorageException
46
     * @return IStorage
47
     */
48 1
    public static function getMultiStorage($params, ?string $alias = null, ?IStTranslations $lang = null): IStorage
49
    {
50 1
        return Access\MultitonInstances::getInstance($lang)->lookup($params, $alias);
51
    }
52
}
53