@@ 144-156 (lines=13) @@ | ||
141 | * @param string $type |
|
142 | * @return ClassGenerator |
|
143 | */ |
|
144 | public function generateGet(string $name, string $type): ClassGenerator |
|
145 | { |
|
146 | $this->class |
|
147 | ->addMethod(static::camelCase('get_' . $name)) |
|
148 | ->addComment( |
|
149 | '@return null|' . $this->getCommentTypeHint($type) |
|
150 | )->setReturnType($this->getTypeHint($type)) |
|
151 | ->setReturnNullable(true) |
|
152 | ->setBody( |
|
153 | 'return isset($this->__' . $name . '__[0]) ? $this->__' . $name . '__[0] : $this->__' . $name . '__[1];' |
|
154 | ); |
|
155 | return $this; |
|
156 | } |
|
157 | ||
158 | /** |
|
159 | * @param string $name |
|
@@ 219-231 (lines=13) @@ | ||
216 | * @param string $type |
|
217 | * @return ClassGenerator |
|
218 | */ |
|
219 | public function generateArrayGet(string $name, string $type): ClassGenerator |
|
220 | { |
|
221 | $this->class |
|
222 | ->addMethod(static::camelCase('get_' . $name)) |
|
223 | ->addComment( |
|
224 | '@return ' . $this->getCommentTypeHint($type) |
|
225 | )->setReturnType($this->getTypeHint($type)) |
|
226 | ->setReturnNullable(true) |
|
227 | ->setBody( |
|
228 | 'return isset($this->__' . $name . '__[0]) ? $this->__' . $name . '__[0] : null;' |
|
229 | ); |
|
230 | return $this; |
|
231 | } |
|
232 | ||
233 | /** |
|
234 | * @param string $name |