Completed
Push — master ( b7cb0e...ffcfdb )
by Дмитрий
02:53
created

AliasManager::setNamespace()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA;
7
8
class AliasManager
9
{
10
    /**
11
     * Current namespace, but this can be null
12
     * @var string|null
13
     */
14
    protected $namespace;
15
16
    /**
17
     * @var string[]
18
     */
19
    protected $aliases = array();
20
21
    /**
22
     * @param string|null $namespace
23
     */
24 6
    public function __construct($namespace = null)
25
    {
26 6
        $this->namespace = $namespace;
27 6
    }
28
29
    public function isClassImported($classNS)
30
    {
31
        if (isset($this->aliases[$classNS])) {
32
            return true;
33
        }
34
35
        return false;
36
    }
37
38
    /**
39
     * @param $namespace
40
     */
41
    public function add($namespace)
42
    {
43
        $this->aliases[] = $namespace;
44
    }
45
46
    /**
47
     * @return null|string
48
     */
49 6
    public function getNamespace()
50
    {
51 6
        return $this->namespace;
52
    }
53
54
    /**
55
     * @param null|string $namespace
56
     */
57 6
    public function setNamespace($namespace)
58
    {
59 6
        $this->namespace = $namespace;
60 6
    }
61
}
62