Code Duplication    Length = 14-19 lines in 4 locations

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/SqlServerAdapter.php 1 location

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

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

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

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

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