AliasHelper::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace WebComplete\core\utils\alias;
4
5
class AliasHelper
6
{
7
8
    protected static $aliasService;
9
10
    /**
11
     * @param string $alias
12
     * @param string $value
13
     *
14
     * @throws \Exception
15
     */
16
    public static function setAlias(string $alias, string $value)
17
    {
18
        self::getInstance()->setAlias($alias, $value);
19
    }
20
21
    /**
22
     * @param $alias
23
     * @param bool $throwException
24
     *
25
     * @return string|null
26
     * @throws \Exception
27
     */
28
    public static function get($alias, $throwException = true)
29
    {
30
        return self::getInstance()->get($alias, $throwException);
31
    }
32
33
    /**
34
     * @param AliasService $service
35
     */
36
    public static function setInstance(AliasService $service)
37
    {
38
        self::$aliasService = $service;
39
    }
40
41
    /**
42
     * @return AliasService
43
     * @throws \WebComplete\core\utils\alias\AliasException
44
     */
45
    protected static function getInstance(): AliasService
46
    {
47
        return self::$aliasService ?? new AliasService([]);
48
    }
49
}
50