1 | <?php |
||
13 | trait ConstantsPart { |
||
14 | |||
15 | /** @var PhpConstant[] */ |
||
16 | private $constants = []; |
||
17 | |||
18 | /** |
||
19 | * Sets a collection of constants |
||
20 | * |
||
21 | * @param array|PhpConstant[] $constants |
||
22 | * @return $this |
||
23 | */ |
||
24 | 5 | public function setConstants(array $constants) { |
|
42 | |||
43 | /** |
||
44 | * Adds a constant |
||
45 | * |
||
46 | * @param string|PhpConstant $nameOrConstant constant name or instance |
||
47 | * @param string $value |
||
48 | * @return $this |
||
49 | */ |
||
50 | 11 | public function setConstant($nameOrConstant, $value = null) { |
|
64 | |||
65 | /** |
||
66 | * Removes a constant |
||
67 | * |
||
68 | * @param string|PhpConstant $nameOrConstant constant name |
||
69 | * @throws \InvalidArgumentException If the constant cannot be found |
||
70 | * @return $this |
||
71 | */ |
||
72 | 2 | public function removeConstant($nameOrConstant) { |
|
85 | |||
86 | /** |
||
87 | * Checks whether a constant exists |
||
88 | * |
||
89 | * @param string|PhpConstant $nameOrConstant |
||
90 | * @return bool |
||
91 | */ |
||
92 | 2 | public function hasConstant($nameOrConstant) { |
|
98 | |||
99 | /** |
||
100 | * Returns a constant. |
||
101 | * |
||
102 | * @param string|PhpConstant $nameOrConstant |
||
103 | * @throws \InvalidArgumentException If the constant cannot be found |
||
104 | * @return PhpConstant |
||
105 | */ |
||
106 | 5 | public function getConstant($nameOrConstant) { |
|
117 | |||
118 | /** |
||
119 | * Returns all constants |
||
120 | * |
||
121 | * @return PhpConstant[] |
||
122 | */ |
||
123 | 13 | public function getConstants() { |
|
126 | |||
127 | /** |
||
128 | * Returns all constant names |
||
129 | * |
||
130 | * @return string[] |
||
131 | */ |
||
132 | 1 | public function getConstantNames() { |
|
135 | |||
136 | /** |
||
137 | * Clears all constants |
||
138 | * |
||
139 | * @return $this |
||
140 | */ |
||
141 | 1 | public function clearConstants() { |
|
146 | } |
||
147 |