Code Duplication    Length = 14-19 lines in 3 locations

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

@@ 547-563 (lines=17) @@
544
    /**
545
     * {@inheritdoc}
546
     */
547
    public function hasIndex($tableName, $columns)
548
    {
549
        if (is_string($columns)) {
550
            $columns = [$columns]; // str to array
551
        }
552
553
        $columns = array_map('strtolower', $columns);
554
        $indexes = $this->getIndexes($tableName);
555
556
        foreach ($indexes as $index) {
557
            if ($columns == $index['columns']) {
558
                return true;
559
            }
560
        }
561
562
        return false;
563
    }
564
565
    /**
566
     * {@inheritdoc}

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

@@ 715-733 (lines=19) @@
712
    /**
713
     * {@inheritdoc}
714
     */
715
    public function hasIndex($tableName, $columns)
716
    {
717
        if (is_string($columns)) {
718
            $columns = [$columns]; // str to array
719
        }
720
721
        $columns = array_map('strtolower', $columns);
722
        $indexes = $this->getIndexes($tableName);
723
724
        foreach ($indexes as $index) {
725
            $a = array_diff($columns, $index['columns']);
726
727
            if (empty($a)) {
728
                return true;
729
            }
730
        }
731
732
        return false;
733
    }
734
735
    /**
736
     * {@inheritdoc}

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

@@ 649-662 (lines=14) @@
646
    /**
647
     * {@inheritdoc}
648
     */
649
    public function hasIndex($tableName, $columns)
650
    {
651
        if (is_string($columns)) {
652
            $columns = [$columns];
653
        }
654
        $indexes = $this->getIndexes($tableName);
655
        foreach ($indexes as $index) {
656
            if (array_diff($index['columns'], $columns) === array_diff($columns, $index['columns'])) {
657
                return true;
658
            }
659
        }
660
661
        return false;
662
    }
663
664
    /**
665
     * {@inheritdoc}