Code Duplication    Length = 29-31 lines in 2 locations

app/src/Console/Commands/GenerateMigrationCommand.php 1 location

@@ 36-66 (lines=31) @@
33
     * @return int|null|void
34
     * @throws \Exception
35
     */
36
    protected function execute(InputInterface $input, OutputInterface $output)
37
    {
38
        $output->writeln(['<comment>Welcome to the migration generator</comment>']);
39
40
        $helper   = $this->getHelper('question');
41
        $question = new Question('<info>Please enter the name of the migration: </info>');
42
        $question->setValidator(function ($answer) {
43
            if (strlen(trim($answer)) === 0) {
44
                throw new \RunTimeException('The name of the migration should be not empty');
45
            }
46
47
            return $answer;
48
        });
49
50
        $migrationName = $helper->ask($input, $output, $question);
51
        $path          = $this->getPathForMigration($migrationName);
52
        $placeHolders  = [
53
            '<class>',
54
            '<tableName>',
55
        ];
56
        $replacements  = [
57
            Helper::underscoreToCamelCase($migrationName, true),
58
            strtolower($migrationName),
59
        ];
60
61
        $this->generateCode($placeHolders, $replacements, 'MigrationTemplate.tpl', $path);
62
63
        $output->writeln(sprintf('Generated new migration class to "<info>%s</info>"', realpath($path)));
64
65
        return;
66
    }
67
68
    /**
69
     * Generate code

app/src/Console/Commands/GenerateSeedCommand.php 1 location

@@ 35-63 (lines=29) @@
32
     * @return int|null|void
33
     * @throws \Exception
34
     */
35
    protected function execute(InputInterface $input, OutputInterface $output)
36
    {
37
        $output->writeln(['<comment>Welcome to the seed generator</comment>']);
38
39
        $helper   = $this->getHelper('question');
40
        $question = new Question('<info>Please enter the name of the seed: </info>');
41
        $question->setValidator(function ($answer) {
42
            if (strlen(trim($answer)) === 0) {
43
                throw new \RunTimeException('The name of the seed should be not empty');
44
            }
45
46
            return $answer;
47
        });
48
49
        $seedName     = $helper->ask($input, $output, $question);
50
        $path         = $this->getPathForSeed($seedName);
51
        $placeHolders = [
52
            '<class>',
53
        ];
54
        $replacements = [
55
            Helper::underscoreToCamelCase($seedName, true),
56
        ];
57
58
        $this->generateCode($placeHolders, $replacements, 'SeedTemplate.tpl', $path);
59
60
        $output->writeln(sprintf('Generated new seed class to "<info>%s</info>"', realpath($path)));
61
62
        return;
63
    }
64
65
    /**
66
     * Generate code