Code Duplication    Length = 14-19 lines in 4 locations

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

@@ 705-723 (lines=19) @@
702
    /**
703
     * {@inheritdoc}
704
     */
705
    public function hasIndex($tableName, $columns)
706
    {
707
        if (is_string($columns)) {
708
            $columns = [$columns]; // str to array
709
        }
710
711
        $columns = array_map('strtolower', $columns);
712
        $indexes = $this->getIndexes($tableName);
713
714
        foreach ($indexes as $index) {
715
            $a = array_diff($columns, $index['columns']);
716
717
            if (empty($a)) {
718
                return true;
719
            }
720
        }
721
722
        return false;
723
    }
724
725
    /**
726
     * {@inheritdoc}

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

@@ 537-553 (lines=17) @@
534
    /**
535
     * {@inheritdoc}
536
     */
537
    public function hasIndex($tableName, $columns)
538
    {
539
        if (is_string($columns)) {
540
            $columns = [$columns]; // str to array
541
        }
542
543
        $columns = array_map('strtolower', $columns);
544
        $indexes = $this->getIndexes($tableName);
545
546
        foreach ($indexes as $index) {
547
            if ($columns == $index['columns']) {
548
                return true;
549
            }
550
        }
551
552
        return false;
553
    }
554
555
    /**
556
     * {@inheritdoc}

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

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

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

@@ 642-655 (lines=14) @@
639
    /**
640
     * {@inheritdoc}
641
     */
642
    public function hasIndex($tableName, $columns)
643
    {
644
        if (is_string($columns)) {
645
            $columns = [$columns];
646
        }
647
        $indexes = $this->getIndexes($tableName);
648
        foreach ($indexes as $index) {
649
            if (array_diff($index['columns'], $columns) === array_diff($columns, $index['columns'])) {
650
                return true;
651
            }
652
        }
653
654
        return false;
655
    }
656
657
    /**
658
     * {@inheritdoc}