Passed
Push — master ( d8770a...53dab7 )
by Maxim
06:55
created

AliasHelper::get()   A

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
26
     * @throws \Exception
27
     */
28
    public static function get($alias, $throwException = true): string
29
    {
30
        return self::getInstance()->get($alias, $throwException);
0 ignored issues
show
Bug Best Practice introduced by
The expression return self::getInstance...alias, $throwException) could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
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
     */
44
    protected static function getInstance(): AliasService
45
    {
46
        return self::$aliasService ?? new AliasService([]);
47
    }
48
}
49