Code Duplication    Length = 14-19 lines in 4 locations

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

@@ 584-600 (lines=17) @@
581
    /**
582
     * {@inheritdoc}
583
     */
584
    public function hasIndex($tableName, $columns)
585
    {
586
        if (is_string($columns)) {
587
            $columns = [$columns]; // str to array
588
        }
589
590
        $columns = array_map('strtolower', $columns);
591
        $indexes = $this->getIndexes($tableName);
592
593
        foreach ($indexes as $index) {
594
            if ($columns == $index['columns']) {
595
                return true;
596
            }
597
        }
598
599
        return false;
600
    }
601
602
    /**
603
     * {@inheritdoc}

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

@@ 668-681 (lines=14) @@
665
    /**
666
     * {@inheritdoc}
667
     */
668
    public function hasIndex($tableName, $columns)
669
    {
670
        if (is_string($columns)) {
671
            $columns = [$columns];
672
        }
673
        $indexes = $this->getIndexes($tableName);
674
        foreach ($indexes as $index) {
675
            if (array_diff($index['columns'], $columns) === array_diff($columns, $index['columns'])) {
676
                return true;
677
            }
678
        }
679
680
        return false;
681
    }
682
683
    /**
684
     * {@inheritdoc}

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

@@ 661-678 (lines=18) @@
658
    /**
659
     * {@inheritdoc}
660
     */
661
    public function hasIndex($tableName, $columns)
662
    {
663
        if (is_string($columns)) {
664
            $columns = [$columns]; // str to array
665
        }
666
667
        $columns = array_map('strtolower', $columns);
668
        $indexes = $this->getIndexes($tableName);
669
670
        foreach ($indexes as $index) {
671
            $a = array_diff($columns, $index['columns']);
672
            if (empty($a)) {
673
                return true;
674
            }
675
        }
676
677
        return false;
678
    }
679
680
    /**
681
     * {@inheritdoc}

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

@@ 728-746 (lines=19) @@
725
    /**
726
     * {@inheritdoc}
727
     */
728
    public function hasIndex($tableName, $columns)
729
    {
730
        if (is_string($columns)) {
731
            $columns = [$columns]; // str to array
732
        }
733
734
        $columns = array_map('strtolower', $columns);
735
        $indexes = $this->getIndexes($tableName);
736
737
        foreach ($indexes as $index) {
738
            $a = array_diff($columns, $index['columns']);
739
740
            if (empty($a)) {
741
                return true;
742
            }
743
        }
744
745
        return false;
746
    }
747
748
    /**
749
     * {@inheritdoc}