Code Duplication    Length = 14-19 lines in 3 locations

src/Phinx/Db/Adapter/SqlServerAdapter.php 1 location

@@ 640-658 (lines=19) @@
637
    /**
638
     * {@inheritdoc}
639
     */
640
    public function hasIndex($tableName, $columns)
641
    {
642
        if (is_string($columns)) {
643
            $columns = [$columns]; // str to array
644
        }
645
646
        $columns = array_map('strtolower', $columns);
647
        $indexes = $this->getIndexes($tableName);
648
649
        foreach ($indexes as $index) {
650
            $a = array_diff($columns, $index['columns']);
651
652
            if (empty($a)) {
653
                return true;
654
            }
655
        }
656
657
        return false;
658
    }
659
660
    /**
661
     * {@inheritdoc}

src/Phinx/Db/Adapter/PostgresAdapter.php 1 location

@@ 520-533 (lines=14) @@
517
    /**
518
     * {@inheritdoc}
519
     */
520
    public function hasIndex($tableName, $columns)
521
    {
522
        if (is_string($columns)) {
523
            $columns = [$columns];
524
        }
525
        $columns = array_map('strtolower', $columns);
526
        $indexes = $this->getIndexes($tableName);
527
        foreach ($indexes as $index) {
528
            if (array_diff($index['columns'], $columns) === array_diff($columns, $index['columns'])) {
529
                return true;
530
            }
531
        }
532
533
        return false;
534
    }
535
536
    /**

src/Phinx/Db/Adapter/SQLiteAdapter.php 1 location

@@ 509-526 (lines=18) @@
506
    /**
507
     * {@inheritdoc}
508
     */
509
    public function hasIndex($tableName, $columns)
510
    {
511
        if (is_string($columns)) {
512
            $columns = [$columns]; // str to array
513
        }
514
515
        $columns = array_map('strtolower', $columns);
516
        $indexes = $this->getIndexes($tableName);
517
518
        foreach ($indexes as $index) {
519
            $a = array_diff($columns, $index['columns']);
520
            if (empty($a)) {
521
                return true;
522
            }
523
        }
524
525
        return false;
526
    }
527
528
    /**
529
     * {@inheritdoc}