Code Duplication    Length = 22-22 lines in 2 locations

src/Phinx/Db/Plan/Plan.php 2 locations

@@ 292-313 (lines=22) @@
289
     * @return array A tuple containing the list of actions without actions for dropping the index
290
     * and a list of drop index actions that were removed.
291
     */
292
    protected function forgetDropIndex(Table $table, array $columns, array $actions)
293
    {
294
        $dropIndexActions = new ArrayObject();
295
        $indexes = array_map(function ($alter) use ($table, $columns, $dropIndexActions) {
296
            if ($alter->getTable()->getName() !== $table->getName()) {
297
                return $alter;
298
            }
299
300
            $newAlter = new AlterTable($table);
301
            foreach ($alter->getActions() as $action) {
302
                if ($action instanceof DropIndex && $action->getIndex()->getColumns() === $columns) {
303
                    $dropIndexActions->append($action);
304
                } else {
305
                    $newAlter->addAction($action);
306
                }
307
            }
308
309
            return $newAlter;
310
        }, $actions);
311
312
        return [$indexes, $dropIndexActions->getArrayCopy()];
313
    }
314
315
    /**
316
     * Deletes any RemoveColumn actions for the given table and exact columns
@@ 325-346 (lines=22) @@
322
     * @return array A tuple containing the list of actions without actions for removing the column
323
     * and a list of remove column actions that were removed.
324
     */
325
    protected function forgetRemoveColumn(Table $table, array $columns, array $actions)
326
    {
327
        $removeColumnActions = new ArrayObject();
328
        $indexes = array_map(function ($alter) use ($table, $columns, $removeColumnActions) {
329
            if ($alter->getTable()->getName() !== $table->getName()) {
330
                return $alter;
331
            }
332
333
            $newAlter = new AlterTable($table);
334
            foreach ($alter->getActions() as $action) {
335
                if ($action instanceof RemoveColumn && in_array($action->getColumn()->getName(), $columns, true)) {
336
                    $removeColumnActions->append($action);
337
                } else {
338
                    $newAlter->addAction($action);
339
                }
340
            }
341
342
            return $newAlter;
343
        }, $actions);
344
345
        return [$indexes, $removeColumnActions->getArrayCopy()];
346
    }
347
348
    /**
349
     * Collects all table creation actions from the given intent