Code Duplication    Length = 14-19 lines in 3 locations

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

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

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

@@ 524-537 (lines=14) @@
521
    /**
522
     * {@inheritdoc}
523
     */
524
    public function hasIndex($tableName, $columns)
525
    {
526
        if (is_string($columns)) {
527
            $columns = [$columns];
528
        }
529
        $columns = array_map('strtolower', $columns);
530
        $indexes = $this->getIndexes($tableName);
531
        foreach ($indexes as $index) {
532
            if (array_diff($index['columns'], $columns) === array_diff($columns, $index['columns'])) {
533
                return true;
534
            }
535
        }
536
537
        return false;
538
    }
539
540
    /**

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

@@ 531-548 (lines=18) @@
528
    /**
529
     * {@inheritdoc}
530
     */
531
    public function hasIndex($tableName, $columns)
532
    {
533
        if (is_string($columns)) {
534
            $columns = [$columns]; // str to array
535
        }
536
537
        $columns = array_map('strtolower', $columns);
538
        $indexes = $this->getIndexes($tableName);
539
540
        foreach ($indexes as $index) {
541
            $a = array_diff($columns, $index['columns']);
542
            if (empty($a)) {
543
                return true;
544
            }
545
        }
546
547
        return false;
548
    }
549
550
    /**
551
     * {@inheritdoc}