Completed
Push — develop ( 66de6a...7afc9d )
by Jaap
04:46 queued 03:01
created

Constant::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
c 1
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * This file is part of phpDocumentor.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @copyright 2010-2015 Mike van Riel<[email protected]>
9
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
10
 * @link      http://phpdoc.org
11
 */
12
13
namespace phpDocumentor\Reflection\Php;
14
15
use phpDocumentor\Reflection\DocBlock;
16
use phpDocumentor\Reflection\Element;
17
use phpDocumentor\Reflection\Fqsen;
18
use phpDocumentor\Reflection\Location;
19
20
/**
21
 * Descriptor representing a constant
22
 */
23
final class Constant implements Element
24
{
25
    /**
26
     * @var Fqsen
27
     */
28
    private $fqsen;
29
30
    /**
31
     * @var null|DocBlock
32
     */
33
    private $docBlock;
34
35
    /** @var null|string $value */
36
    protected $value;
37
38
    /**
39
     * @var Location
40
     */
41
    private $location;
42
43
    /**
44
     * Initializes the object.
45
     *
46
     * @param Fqsen $fqsen
47
     * @param DocBlock|null $docBlock
48
     * @param null|string $value
49
     * @param Location|null $location
50
     */
51 3
    public function __construct(Fqsen $fqsen, DocBlock $docBlock = null, $value = null, Location $location = null)
52
    {
53 3
        $this->fqsen = $fqsen;
54 3
        $this->docBlock = $docBlock;
55 3
        $this->value = $value;
56
57 3
        if ($location === null) {
58 3
            $location = new Location(-1);
59
        }
60
61 3
        $this->location = $location;
62 3
    }
63
64
    /**
65
     * Returns the value of this constant.
66
     *
67
     * @return null|string
68
     */
69 1
    public function getValue()
70
    {
71 1
        return $this->value;
72
    }
73
74
    /**
75
     * Returns the Fqsen of the element.
76
     *
77
     * @return Fqsen
78
     */
79 1
    public function getFqsen()
80
    {
81 1
        return $this->fqsen;
82
    }
83
84
    /**
85
     * Returns the name of the element.
86
     *
87
     * @return string
88
     */
89 1
    public function getName()
90
    {
91 1
        return $this->fqsen->getName();
92
    }
93
94
    /**
95
     * Returns DocBlock of this constant if available.
96
     *
97
     * @return null|DocBlock
98
     */
99 1
    public function getDocBlock()
100
    {
101 1
        return $this->docBlock;
102
    }
103
104
    /**
105
     * @return Location
106
     */
107
    public function getLocation()
108
    {
109
        return $this->location;
110
    }
111
}
112