Code Duplication    Length = 37-37 lines in 2 locations

src/Phinx/Console/Command/Create.php 1 location

@@ 105-141 (lines=37) @@
102
     * @return mixed
103
     * @throws \Exception
104
     */
105
    protected function getMigrationPath(InputInterface $input, OutputInterface $output)
106
    {
107
        // First, try the non-interactive option:
108
        $path = $input->getOption('path');
109
110
        if (!empty($path)) {
111
            return $path;
112
        }
113
114
        $paths = $this->getConfig()->getMigrationPaths();
115
116
        // No paths? That's a problem.
117
        if (empty($paths)) {
118
            throw new \Exception('No migration paths set in your Phinx configuration file.');
119
        }
120
121
        $paths = Util::globAll($paths);
122
123
        if (empty($paths)) {
124
            throw new \Exception(
125
                'You probably used curly braces to define migration path in your Phinx configuration file, ' .
126
                'but no directories have been matched using this pattern. ' .
127
                'You need to create a migration directory manually.'
128
            );
129
        }
130
131
        // Only one path set, so select that:
132
        if (1 === count($paths)) {
133
            return array_shift($paths);
134
        }
135
136
        // Ask the user which of their defined paths they'd like to use:
137
        $helper = $this->getHelper('question');
138
        $question = $this->getSelectMigrationPathQuestion($paths);
139
140
        return $helper->ask($input, $output, $question);
141
    }
142
143
    /**
144
     * Create the new migration.

src/Phinx/Console/Command/SeedCreate.php 1 location

@@ 90-126 (lines=37) @@
87
     * @return mixed
88
     * @throws \Exception
89
     */
90
    protected function getSeedPath(InputInterface $input, OutputInterface $output)
91
    {
92
        // First, try the non-interactive option:
93
        $path = $input->getOption('path');
94
95
        if (!empty($path)) {
96
            return $path;
97
        }
98
99
        $paths = $this->getConfig()->getSeedPaths();
100
101
        // No paths? That's a problem.
102
        if (empty($paths)) {
103
            throw new \Exception('No seed paths set in your Phinx configuration file.');
104
        }
105
106
        $paths = Util::globAll($paths);
107
108
        if (empty($paths)) {
109
            throw new \Exception(
110
                'You probably used curly braces to define seed path in your Phinx configuration file, ' .
111
                'but no directories have been matched using this pattern. ' .
112
                'You need to create a seed directory manually.'
113
            );
114
        }
115
116
        // Only one path set, so select that:
117
        if (1 === count($paths)) {
118
            return array_shift($paths);
119
        }
120
121
        // Ask the user which of their defined paths they'd like to use:
122
        $helper = $this->getHelper('question');
123
        $question = $this->getSelectSeedPathQuestion($paths);
124
125
        return $helper->ask($input, $output, $question);
126
    }
127
128
    /**
129
     * Create the new seeder.