Code Duplication    Length = 11-12 lines in 6 locations

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

@@ 453-463 (lines=11) @@
450
     * @param AbstractTable   $table
451
     * @param StateComparator $comparator
452
     */
453
    protected function createForeigns(AbstractTable $table, StateComparator $comparator)
454
    {
455
        foreach ($comparator->addedForeigns() as $foreign) {
456
            $this->log('Adding foreign key [{statement}] into table {table}.', [
457
                'statement' => $foreign->sqlStatement($this->driver),
458
                'table'     => $this->identify($table),
459
            ]);
460
461
            $this->createForeign($table, $foreign);
462
        }
463
    }
464
465
    /**
466
     * @param AbstractTable   $table
@@ 492-502 (lines=11) @@
489
     * @param AbstractTable   $table
490
     * @param StateComparator $comparator
491
     */
492
    protected function createIndexes(AbstractTable $table, StateComparator $comparator)
493
    {
494
        foreach ($comparator->addedIndexes() as $index) {
495
            $this->log('Adding index [{statement}] into table {table}.', [
496
                'statement' => $index->sqlStatement($this->driver),
497
                'table'     => $this->identify($table),
498
            ]);
499
500
            $this->createIndex($table, $index);
501
        }
502
    }
503
504
    /**
505
     * @param AbstractTable   $table
@@ 532-543 (lines=12) @@
529
     * @param AbstractTable   $table
530
     * @param StateComparator $comparator
531
     */
532
    protected function createColumns(AbstractTable $table, StateComparator $comparator)
533
    {
534
        foreach ($comparator->addedColumns() as $column) {
535
            $this->log('Adding column [{statement}] into table {table}.', [
536
                'statement' => $column->sqlStatement($this->driver),
537
                'table'     => $this->identify($table),
538
            ]);
539
540
            $this->assertValid($column);
541
            $this->createColumn($table, $column);
542
        }
543
    }
544
545
    /**
546
     * @param AbstractTable   $table
@@ 549-559 (lines=11) @@
546
     * @param AbstractTable   $table
547
     * @param StateComparator $comparator
548
     */
549
    protected function dropColumns(AbstractTable $table, StateComparator $comparator)
550
    {
551
        foreach ($comparator->droppedColumns() as $column) {
552
            $this->log('Dropping column [{statement}] from table {table}.', [
553
                'statement' => $column->sqlStatement($this->driver),
554
                'table'     => $this->identify($table),
555
            ]);
556
557
            $this->dropColumn($table, $column);
558
        }
559
    }
560
561
    /**
562
     * @param AbstractTable   $table
@@ 565-575 (lines=11) @@
562
     * @param AbstractTable   $table
563
     * @param StateComparator $comparator
564
     */
565
    protected function dropIndexes(AbstractTable $table, StateComparator $comparator)
566
    {
567
        foreach ($comparator->droppedIndexes() as $index) {
568
            $this->log('Dropping index [{statement}] from table {table}.', [
569
                'statement' => $index->sqlStatement($this->driver),
570
                'table'     => $this->identify($table),
571
            ]);
572
573
            $this->dropIndex($table, $index);
574
        }
575
    }
576
577
    /**
578
     * @param AbstractTable   $table
@@ 581-591 (lines=11) @@
578
     * @param AbstractTable   $table
579
     * @param StateComparator $comparator
580
     */
581
    protected function dropForeigns(AbstractTable $table, $comparator)
582
    {
583
        foreach ($comparator->droppedForeigns() as $foreign) {
584
            $this->log('Dropping foreign key [{statement}] from table {table}.', [
585
                'statement' => $foreign->sqlStatement($this->driver),
586
                'table'     => $this->identify($table),
587
            ]);
588
589
            $this->dropForeign($table, $foreign);
590
        }
591
    }
592
593
    /**
594
     * Applied to every column in order to make sure that driver support it.