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

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