| @@ 254-271 (lines=18) @@ | ||
| 251 | * @param string $type | |
| 252 | * @return ClassGenerator | |
| 253 | */ | |
| 254 | public function generateListGetAt(string $name, string $type): ClassGenerator | |
| 255 |     { | |
| 256 | $this->class | |
| 257 |             ->addMethod(static::camelCase('get_' . $name . '_at')) | |
| 258 | ->addComment( | |
| 259 | '@param int $index' . PHP_EOL . | |
| 260 | '@return ' . $this->getCommentTypeHint($type) | |
| 261 | )->setReturnType($this->getTypeHint($type)) | |
| 262 | ->setReturnNullable(true) | |
| 263 | ->setBody( | |
| 264 |                 'if (isset($this->__' . $name . '__[0]) && array_key_exists($index, $this->__' . $name . '__[0])) {' . | |
| 265 | PHP_EOL . ' return $this->__' . $name . '__[0][$index];' . PHP_EOL . | |
| 266 | '}' . PHP_EOL . | |
| 267 | 'return null;' | |
| 268 |             )->addParameter('index') | |
| 269 |             ->setTypeHint('int'); | |
| 270 | return $this; | |
| 271 | } | |
| 272 | ||
| 273 | /** | |
| 274 | * @param string $name | |
| @@ 382-398 (lines=17) @@ | ||
| 379 | * @param string $type | |
| 380 | * @return ClassGenerator | |
| 381 | */ | |
| 382 | public function generateMapGetAt(string $name, string $type): ClassGenerator | |
| 383 |     { | |
| 384 | $this->class | |
| 385 |             ->addMethod(static::camelCase('get_' . $name . '_at')) | |
| 386 | ->addComment( | |
| 387 | '@param mixed $key' . PHP_EOL . | |
| 388 | '@return ' . $this->getCommentTypeHint($type) | |
| 389 | )->setReturnType($this->getTypeHint($type)) | |
| 390 | ->setReturnNullable(true) | |
| 391 | ->setBody( | |
| 392 |                 'if (isset($this->__' . $name . '__[0]) && array_key_exists($key, $this->__' . $name . '__[0])) {' . | |
| 393 | PHP_EOL . ' return $this->__' . $name . '__[0][$key];' . PHP_EOL . | |
| 394 | '}' . PHP_EOL . | |
| 395 | 'return null;' | |
| 396 |             )->addParameter('key'); | |
| 397 | return $this; | |
| 398 | } | |
| 399 | ||
| 400 | /** | |
| 401 | * @param string $name | |