| @@ 118-130 (lines=13) @@ | ||
| 115 | * @param string $type |
|
| 116 | * @return ClassGenerator |
|
| 117 | */ |
|
| 118 | public function generateGet(string $name, string $type): ClassGenerator |
|
| 119 | { |
|
| 120 | $this->class |
|
| 121 | ->addMethod(static::camelCase('get_' . $name)) |
|
| 122 | ->addComment( |
|
| 123 | '@return null|' . $this->getCommentTypeHint($type) |
|
| 124 | )->setReturnType($this->getTypeHint($type)) |
|
| 125 | ->setReturnNullable(true) |
|
| 126 | ->setBody( |
|
| 127 | 'return isset($this->__' . $name . '__[0]) ? $this->__' . $name . '__[0] : $this->__' . $name . '__[1];' |
|
| 128 | ); |
|
| 129 | return $this; |
|
| 130 | } |
|
| 131 | ||
| 132 | /** |
|
| 133 | * @param string $name |
|
| @@ 193-205 (lines=13) @@ | ||
| 190 | * @param string $type |
|
| 191 | * @return ClassGenerator |
|
| 192 | */ |
|
| 193 | public function generateArrayGet(string $name, string $type): ClassGenerator |
|
| 194 | { |
|
| 195 | $this->class |
|
| 196 | ->addMethod(static::camelCase('get_' . $name)) |
|
| 197 | ->addComment( |
|
| 198 | '@return ' . $this->getCommentTypeHint($type) |
|
| 199 | )->setReturnType($this->getTypeHint($type)) |
|
| 200 | ->setReturnNullable(true) |
|
| 201 | ->setBody( |
|
| 202 | 'return isset($this->__' . $name . '__[0]) ? $this->__' . $name . '__[0] : null;' |
|
| 203 | ); |
|
| 204 | return $this; |
|
| 205 | } |
|
| 206 | ||
| 207 | /** |
|
| 208 | * @param string $name |
|