Completed
Push — master ( 780ea5...d11bf8 )
by Alexey
04:00
created

UseStatement::getUse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Reflection\ClassUseStatements;
6
7
/**
8
 * Class UseStatement
9
 * @package UsesReflection
10
 */
11
class UseStatement {
12
13
    /**
14
     * @var string
15
     */
16
    private $use;
17
18
    /**
19
     * @var string
20
     */
21
    private $alias;
22
23
    /**
24
     * UseStatement constructor.
25
     * @param string $use
26
     * @param string $alias
27
     */
28 1
    public function __construct(string $use, string $alias = '') {
29 1
        $this->setUse($use)
30 1
            ->setAlias($alias);
31 1
    }
32
33
    /**
34
     * @return string
35
     */
36 1
    public function getUse(): string {
37 1
        return $this->use;
38
    }
39
40
    /**
41
     * @param string $use
42
     * @return UseStatement
43
     */
44 1
    public function setUse(string $use): UseStatement {
45 1
        if ($use[0] !== '\\') {
46 1
            $use = "\\$use";
47
        }
48
49 1
        $this->use = $use;
50
51 1
        return $this;
52
    }
53
54
    /**
55
     * @return string
56
     */
57 1
    public function getAlias(): string {
58 1
        return $this->alias;
59
    }
60
61
    /**
62
     * @param string $alias
63
     * @return UseStatement
64
     */
65 1
    public function setAlias(string $alias): UseStatement {
66 1
        $this->alias = $alias;
67
68 1
        return $this;
69
    }
70
71
    /**
72
     * @param string $statement
73
     * @return bool
74
     */
75 1
    public function isEqual(string $statement): bool {
76 1
        if ($statement === $this->getUse()) {
77 1
            return true;
78
        }
79
80 1
        if ($statement === $this->getAlias()) {
81 1
            return true;
82
        }
83
84 1
        return false;
85
    }
86
87
}