Code Duplication    Length = 14-19 lines in 4 locations

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

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

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

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

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

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

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}