Code Duplication    Length = 14-19 lines in 4 locations

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

@@ 487-503 (lines=17) @@
484
    /**
485
     * {@inheritdoc}
486
     */
487
    public function hasIndex($tableName, $columns)
488
    {
489
        if (is_string($columns)) {
490
            $columns = [$columns]; // str to array
491
        }
492
493
        $columns = array_map('strtolower', $columns);
494
        $indexes = $this->getIndexes($tableName);
495
496
        foreach ($indexes as $index) {
497
            if ($columns == $index['columns']) {
498
                return true;
499
            }
500
        }
501
502
        return false;
503
    }
504
505
    /**
506
     * {@inheritdoc}

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

@@ 581-594 (lines=14) @@
578
    /**
579
     * {@inheritdoc}
580
     */
581
    public function hasIndex($tableName, $columns)
582
    {
583
        if (is_string($columns)) {
584
            $columns = [$columns];
585
        }
586
        $indexes = $this->getIndexes($tableName);
587
        foreach ($indexes as $index) {
588
            if (array_diff($index['columns'], $columns) === array_diff($columns, $index['columns'])) {
589
                return true;
590
            }
591
        }
592
593
        return false;
594
    }
595
596
    /**
597
     * {@inheritdoc}

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

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

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

@@ 601-618 (lines=18) @@
598
    /**
599
     * {@inheritdoc}
600
     */
601
    public function hasIndex($tableName, $columns)
602
    {
603
        if (is_string($columns)) {
604
            $columns = [$columns]; // str to array
605
        }
606
607
        $columns = array_map('strtolower', $columns);
608
        $indexes = $this->getIndexes($tableName);
609
610
        foreach ($indexes as $index) {
611
            $a = array_diff($columns, $index['columns']);
612
            if (empty($a)) {
613
                return true;
614
            }
615
        }
616
617
        return false;
618
    }
619
620
    /**
621
     * {@inheritdoc}