Code Duplication    Length = 18-18 lines in 2 locations

classes/ClassGenerator.php 2 locations

@@ 328-345 (lines=18) @@
325
     * @param string $type
326
     * @return ClassGenerator
327
     */
328
    public function generateArrayPush(string $name, string $type): ClassGenerator
329
    {
330
        $this->class
331
            ->addMethod(static::camelCase('push_' . $name))
332
            ->addComment(
333
                '@param ' . $this->getCommentTypeHint($type) . ' $value' . PHP_EOL .
334
                '@return ' . $this->class->getName()
335
            )->setReturnType($this->getCanonicalClassName())
336
            ->setBody(
337
                'if (!isset($this->__' . $name . '__[0])) {' . PHP_EOL .
338
                '    $this->__' . $name . '__[0] = [];' . PHP_EOL .
339
                '}' . PHP_EOL .
340
                'array_push($this->__' . $name . '__[0], $value);' . PHP_EOL .
341
                'return $this;'
342
            )->addParameter('value')
343
            ->setTypeHint($this->getTypeHint($type));
344
        return $this;
345
    }
346
347
    /**
348
     * @param string $name
@@ 352-369 (lines=18) @@
349
     * @param string $type
350
     * @return ClassGenerator
351
     */
352
    public function generateArrayUnshift(string $name, string $type): ClassGenerator
353
    {
354
        $this->class
355
            ->addMethod(static::camelCase('unshift_' . $name))
356
            ->addComment(
357
                '@param ' . $this->getCommentTypeHint($type) . ' $value' . PHP_EOL .
358
                '@return ' . $this->class->getName()
359
            )->setReturnType($this->getCanonicalClassName())
360
            ->setBody(
361
                'if (!isset($this->__' . $name . '__[0])) {' . PHP_EOL .
362
                '    $this->__' . $name . '__[0] = [];' . PHP_EOL .
363
                '}' . PHP_EOL .
364
                'array_unshift($this->__' . $name . '__[0], $value);' . PHP_EOL .
365
                'return $this;'
366
            )->addParameter('value')
367
            ->setTypeHint($this->getTypeHint($type));
368
        return $this;
369
    }
370
371
    /**
372
     * @param string $name