@@ 387-402 (lines=16) @@ | ||
384 | * @param string $type |
|
385 | * @return ClassGenerator |
|
386 | */ |
|
387 | public function generateArrayPop(string $name, string $type): ClassGenerator |
|
388 | { |
|
389 | $this->class |
|
390 | ->addMethod(static::camelCase('pop_' . $name)) |
|
391 | ->addComment( |
|
392 | '@return null|' . $this->getCommentTypeHint($type) |
|
393 | )->setReturnType($this->getTypeHint($type)) |
|
394 | ->setReturnNullable(true) |
|
395 | ->setBody( |
|
396 | 'if (!isset($this->__' . $name . '__[0])) {' . PHP_EOL . |
|
397 | ' return null;' . PHP_EOL . |
|
398 | '}' . PHP_EOL . |
|
399 | 'return array_pop($this->__' . $name . '__[0]);' |
|
400 | ); |
|
401 | return $this; |
|
402 | } |
|
403 | ||
404 | /** |
|
405 | * @param string $name |
|
@@ 409-424 (lines=16) @@ | ||
406 | * @param string $type |
|
407 | * @return ClassGenerator |
|
408 | */ |
|
409 | public function generateArrayShift(string $name, string $type): ClassGenerator |
|
410 | { |
|
411 | $this->class |
|
412 | ->addMethod(static::camelCase('shift_' . $name)) |
|
413 | ->addComment( |
|
414 | '@return null|' . $this->getCommentTypeHint($type) |
|
415 | )->setReturnType($this->getTypeHint($type)) |
|
416 | ->setReturnNullable(true) |
|
417 | ->setBody( |
|
418 | 'if (!isset($this->__' . $name . '__[0])) {' . PHP_EOL . |
|
419 | ' return null;' . PHP_EOL . |
|
420 | '}' . PHP_EOL . |
|
421 | 'return array_shift($this->__' . $name . '__[0]);' |
|
422 | ); |
|
423 | return $this; |
|
424 | } |
|
425 | ||
426 | /** |
|
427 | * @param string $name |