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

Property::getVisibility()   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
use phpDocumentor\Reflection\Php\Visibility;
20
21
/**
22
 * Descriptor representing a property.
23
 */
24
final class Property implements Element
25
{
26
    /**
27
     * @var Fqsen
28
     */
29
    private $fqsen;
30
31
    /**
32
     * @var DocBlock|null
33
     */
34
    private $docBlock;
35
36
    /** @var string[] $types */
37
    private $types = array();
38
39
    /** @var string $default */
40
    private $default = null;
41
42
    /** @var bool $static */
43
    private $static = false;
44
45
    /** @var Visibility $visibility */
46
    private $visibility;
47
48
    /**
49
     * @var Location
50
     */
51
    private $location;
52
53
    /**
54
     * @param Fqsen $fqsen
55
     * @param Visibility|null $visibility when null is provided a default 'public' is set.
56
     * @param DocBlock|null $docBlock
57
     * @param null|string $default
58
     * @param bool $static
59
     * @param Location|null $location
60
     */
61 5
    public function __construct(
62
        Fqsen $fqsen,
63
        Visibility $visibility = null,
64
        DocBlock $docBlock = null,
65
        $default = null,
66
        $static = false,
67
        Location $location = null
68
    ) {
69 5
        if ($location === null) {
70 5
            $location = new Location(-1);
71
        }
72
73 5
        $this->fqsen = $fqsen;
74 5
        $this->visibility = $visibility;
75 5
        $this->docBlock = $docBlock;
76 5
        $this->default = $default;
77 5
        $this->static = $static;
78 5
        $this->location = $location;
79
80 5
        if ($this->visibility === null) {
81 1
            $this->visibility = new Visibility('public');
82
        }
83
84 5
    }
85
86
    /**
87
     * returns the default value of this property.
88
     *
89
     * @return string
90
     */
91 1
    public function getDefault()
92
    {
93 1
        return $this->default;
94
    }
95
96
    /**
97
     * Returns true when this method is static. Otherwise returns false.
98
     *
99
     * @return bool
100
     */
101 1
    public function isStatic()
102
    {
103 1
        return $this->static;
104
    }
105
106
    /**
107
     * Returns the types of this property.
108
     *
109
     * @return string[]
110
     */
111 1
    public function getTypes()
112
    {
113 1
        return $this->types;
114
    }
115
116
    /**
117
     * Add a type to this property
118
     *
119
     * @param string $type
120
     * @return void
121
     */
122 1
    public function addType($type)
123
    {
124 1
        $this->types[] = $type;
125 1
    }
126
127
    /**
128
     * Return visibility of the property.
129
     *
130
     * @return Visibility
131
     */
132 1
    public function getVisibility()
133
    {
134 1
        return $this->visibility;
135
    }
136
137
    /**
138
     * Returns the Fqsen of the element.
139
     *
140
     * @return Fqsen
141
     */
142 1
    public function getFqsen()
143
    {
144 1
        return $this->fqsen;
145
    }
146
147
    /**
148
     * Returns the name of the element.
149
     *
150
     * @return string
151
     */
152 1
    public function getName()
153
    {
154 1
        return $this->fqsen->getName();
155
    }
156
157
    /**
158
     * Returns the DocBlock of this property.
159
     *
160
     * @return DocBlock|null
161
     */
162 1
    public function getDocBlock()
163
    {
164 1
        return $this->docBlock;
165
    }
166
167
    /**
168
     * @return Location
169
     */
170
    public function getLocation()
171
    {
172
        return $this->location;
173
    }
174
}
175