Helper::initStorage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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