Code Duplication    Length = 22-22 lines in 2 locations

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

@@ 312-333 (lines=22) @@
309
     * @return array A tuple containing the list of actions without actions for dropping the index
310
     * and a list of drop index actions that were removed.
311
     */
312
    protected function forgetDropIndex(Table $table, array $columns, array $actions)
313
    {
314
        $dropIndexActions = new ArrayObject();
315
        $indexes = array_map(function ($alter) use ($table, $columns, $dropIndexActions) {
316
            if ($alter->getTable()->getName() !== $table->getName()) {
317
                return $alter;
318
            }
319
320
            $newAlter = new AlterTable($table);
321
            foreach ($alter->getActions() as $action) {
322
                if ($action instanceof DropIndex && $action->getIndex()->getColumns() === $columns) {
323
                    $dropIndexActions->append($action);
324
                } else {
325
                    $newAlter->addAction($action);
326
                }
327
            }
328
329
            return $newAlter;
330
        }, $actions);
331
332
        return [$indexes, $dropIndexActions->getArrayCopy()];
333
    }
334
335
    /**
336
     * Deletes any RemoveColumn actions for the given table and exact columns
@@ 345-366 (lines=22) @@
342
     * @return array A tuple containing the list of actions without actions for removing the column
343
     * and a list of remove column actions that were removed.
344
     */
345
    protected function forgetRemoveColumn(Table $table, array $columns, array $actions)
346
    {
347
        $removeColumnActions = new ArrayObject();
348
        $indexes = array_map(function ($alter) use ($table, $columns, $removeColumnActions) {
349
            if ($alter->getTable()->getName() !== $table->getName()) {
350
                return $alter;
351
            }
352
353
            $newAlter = new AlterTable($table);
354
            foreach ($alter->getActions() as $action) {
355
                if ($action instanceof RemoveColumn && in_array($action->getColumn()->getName(), $columns, true)) {
356
                    $removeColumnActions->append($action);
357
                } else {
358
                    $newAlter->addAction($action);
359
                }
360
            }
361
362
            return $newAlter;
363
        }, $actions);
364
365
        return [$indexes, $removeColumnActions->getArrayCopy()];
366
    }
367
368
    /**
369
     * Collects all table creation actions from the given intent