Code Duplication    Length = 11-12 lines in 6 locations

source/Spiral/Database/Entities/AbstractHandler.php 6 locations

@@ 542-552 (lines=11) @@
539
     * @param AbstractTable   $table
540
     * @param StateComparator $comparator
541
     */
542
    protected function dropColumns(AbstractTable $table, StateComparator $comparator)
543
    {
544
        foreach ($comparator->droppedColumns() as $column) {
545
            $this->log('Dropping column [{statement}] from table {table}.', [
546
                'statement' => $column->sqlStatement($this->driver),
547
                'table'     => $this->identify($table),
548
            ]);
549
550
            $this->dropColumn($table, $column);
551
        }
552
    }
553
554
    /**
555
     * @param AbstractTable   $table
@@ 558-568 (lines=11) @@
555
     * @param AbstractTable   $table
556
     * @param StateComparator $comparator
557
     */
558
    protected function dropIndexes(AbstractTable $table, StateComparator $comparator)
559
    {
560
        foreach ($comparator->droppedIndexes() as $index) {
561
            $this->log('Dropping index [{statement}] from table {table}.', [
562
                'statement' => $index->sqlStatement($this->driver),
563
                'table'     => $this->identify($table),
564
            ]);
565
566
            $this->dropIndex($table, $index);
567
        }
568
    }
569
570
    /**
571
     * @param AbstractTable   $table
@@ 574-584 (lines=11) @@
571
     * @param AbstractTable   $table
572
     * @param StateComparator $comparator
573
     */
574
    protected function dropForeigns(AbstractTable $table, $comparator)
575
    {
576
        foreach ($comparator->droppedForeigns() as $foreign) {
577
            $this->log('Dropping foreign key [{statement}] from table {table}.', [
578
                'statement' => $foreign->sqlStatement($this->driver),
579
                'table'     => $this->identify($table),
580
            ]);
581
582
            $this->dropForeign($table, $foreign);
583
        }
584
    }
585
586
    /**
587
     * Applied to every column in order to make sure that driver support it.
@@ 446-456 (lines=11) @@
443
     * @param AbstractTable   $table
444
     * @param StateComparator $comparator
445
     */
446
    protected function createForeigns(AbstractTable $table, StateComparator $comparator)
447
    {
448
        foreach ($comparator->addedForeigns() as $foreign) {
449
            $this->log('Adding foreign key [{statement}] into table {table}.', [
450
                'statement' => $foreign->sqlStatement($this->driver),
451
                'table'     => $this->identify($table),
452
            ]);
453
454
            $this->createForeign($table, $foreign);
455
        }
456
    }
457
458
    /**
459
     * @param AbstractTable   $table
@@ 485-495 (lines=11) @@
482
     * @param AbstractTable   $table
483
     * @param StateComparator $comparator
484
     */
485
    protected function createIndexes(AbstractTable $table, StateComparator $comparator)
486
    {
487
        foreach ($comparator->addedIndexes() as $index) {
488
            $this->log('Adding index [{statement}] into table {table}.', [
489
                'statement' => $index->sqlStatement($this->driver),
490
                'table'     => $this->identify($table),
491
            ]);
492
493
            $this->createIndex($table, $index);
494
        }
495
    }
496
497
    /**
498
     * @param AbstractTable   $table
@@ 525-536 (lines=12) @@
522
     * @param AbstractTable   $table
523
     * @param StateComparator $comparator
524
     */
525
    protected function createColumns(AbstractTable $table, StateComparator $comparator)
526
    {
527
        foreach ($comparator->addedColumns() as $column) {
528
            $this->log('Adding column [{statement}] into table {table}.', [
529
                'statement' => $column->sqlStatement($this->driver),
530
                'table'     => $this->identify($table),
531
            ]);
532
533
            $this->assertValid($column);
534
            $this->createColumn($table, $column);
535
        }
536
    }
537
538
    /**
539
     * @param AbstractTable   $table