Code Duplication    Length = 20-25 lines in 2 locations

vendor/robmorgan/phinx/src/Phinx/Migration/Manager.php 2 locations

@@ 175-199 (lines=25) @@
172
     *
173
     * @return void
174
     */
175
    public function migrateToDateTime($environment, \DateTime $dateTime)
176
    {
177
        $env            = $this->getEnvironment($environment);
178
        $versions       = array_keys($this->getMigrations());
179
        $dateString     = $dateTime->format('Ymdhis');
180
        $earlierVersion = null;
181
        foreach ($versions as $version) {
182
            if ($version > $dateString) {
183
                if (!is_null($earlierVersion)) {
184
                    $this->getOutput()->writeln(
185
                        'Migrating to version ' . $earlierVersion
186
                    );
187
                }
188
                $this->migrate($environment, $earlierVersion);
189
                return;
190
            }
191
            $earlierVersion = $version;
192
        }
193
        //If the date is greater than the latest version, migrate
194
        //to the latest version.
195
        $this->getOutput()->writeln(
196
            'Migrating to version ' . $earlierVersion
197
        );
198
        $this->migrate($environment, $earlierVersion);
199
    }
200
201
    /**
202
     * Roll back to the version of the database on a given date.
@@ 209-228 (lines=20) @@
206
     *
207
     * @return void
208
     */
209
    public function rollbackToDateTime($environment, \DateTime $dateTime)
210
    {
211
        $env        = $this->getEnvironment($environment);
212
        $versions   = $env->getVersions();
213
        $dateString = $dateTime->format('Ymdhis');
214
        sort($versions);
215
        $laterVersion = null;
216
        foreach (array_reverse($versions) as $version) {
217
            if ($version < $dateString) {
218
                if (!is_null($laterVersion)) {
219
                    $this->getOutput()->writeln('Rolling back to version '.$version);
220
                }
221
                $this->rollback($environment, $version);
222
                return;
223
            }
224
            $laterVersion = $version;
225
        }
226
        $this->getOutput()->writeln('Rolling back to version ' . $laterVersion);
227
        $this->rollback($environment, $laterVersion);
228
    }
229
230
    /**
231
     * Migrate an environment to the specified version.