1 | <?php |
||
14 | trait ParametersPart { |
||
15 | |||
16 | /** @var PhpParameter[] */ |
||
17 | private $parameters = []; |
||
18 | |||
19 | /** |
||
20 | * Sets a collection of parameters |
||
21 | * |
||
22 | * @param PhpParameter[] $parameters |
||
23 | * @return $this |
||
24 | */ |
||
25 | 1 | public function setParameters(array $parameters) { |
|
30 | |||
31 | /** |
||
32 | * Adds a parameter |
||
33 | * |
||
34 | * @param PhpParameter $parameter |
||
35 | * @return $this |
||
36 | */ |
||
37 | 23 | public function addParameter(PhpParameter $parameter) { |
|
42 | |||
43 | /** |
||
44 | * Checks whether a parameter exists |
||
45 | * |
||
46 | * @param string $name parameter name |
||
47 | * @return bool `true` if a parameter exists and `false` if not |
||
48 | */ |
||
49 | 2 | public function hasParameter($name) { |
|
57 | |||
58 | /** |
||
59 | * A quick way to add a parameter which is created from the given parameters |
||
60 | * |
||
61 | * @param string $name |
||
62 | * @param null|string $type |
||
63 | * @param mixed $defaultValue omit the argument to define no default value |
||
64 | * |
||
65 | * @return $this |
||
66 | */ |
||
67 | 1 | public function addSimpleParameter($name, $type = null, $defaultValue = null) { |
|
78 | |||
79 | /** |
||
80 | * A quick way to add a parameter with description which is created from the given parameters |
||
81 | * |
||
82 | * @param string $name |
||
83 | * @param null|string $type |
||
84 | * @param null|string $typeDescription |
||
85 | * @param mixed $defaultValue omit the argument to define no default value |
||
86 | * |
||
87 | * @return $this |
||
88 | */ |
||
89 | 1 | public function addSimpleDescParameter($name, $type = null, $typeDescription = null, $defaultValue = null) { |
|
101 | |||
102 | /** |
||
103 | * Returns a parameter by index or name |
||
104 | * |
||
105 | * @param string|int $nameOrIndex |
||
106 | * @return PhpParameter |
||
107 | */ |
||
108 | 6 | public function getParameter($nameOrIndex) { |
|
127 | |||
128 | /** |
||
129 | * Replaces a parameter at a given position |
||
130 | * |
||
131 | * @param int $position |
||
132 | * @param PhpParameter $parameter |
||
133 | * @throws \InvalidArgumentException |
||
134 | * @return $this |
||
135 | */ |
||
136 | 2 | public function replaceParameter($position, PhpParameter $parameter) { |
|
144 | |||
145 | /** |
||
146 | * Remove a parameter at a given position |
||
147 | * |
||
148 | * @param int $position |
||
149 | * @return $this |
||
150 | */ |
||
151 | 2 | public function removeParameter($position) { |
|
160 | |||
161 | /** |
||
162 | * Returns a collection of parameters |
||
163 | * |
||
164 | * @return PhpParameter[] |
||
165 | */ |
||
166 | 17 | public function getParameters() { |
|
169 | |||
170 | /** |
||
171 | * Returns the docblock |
||
172 | * |
||
173 | * @return Docblock |
||
174 | */ |
||
175 | abstract protected function getDocblock(); |
||
176 | |||
177 | /** |
||
178 | * Generates docblock for params |
||
179 | */ |
||
180 | 14 | protected function generateParamDocblock() { |
|
202 | |||
203 | } |
||
204 |