Completed
Push — feature/test-php-7-2-in-travis ( a56bae...2774bc )
by
unknown
02:41
created

Version20150312162849   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 36
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 11 11 1
A down() 11 11 1
A setContainer() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Surfnet\Migrations;
4
5
use Doctrine\DBAL\Migrations\AbstractMigration;
6
use Doctrine\DBAL\Schema\Schema;
7
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8
use Symfony\Component\DependencyInjection\ContainerInterface;
9
10
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13 View Code Duplication
class Version20150312162849 extends AbstractMigration implements ContainerAwareInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
    /**
16
     * @var \Symfony\Component\DependencyInjection\ContainerInterface
17
     */
18
    private $container;
19
20
    public function up(Schema $schema)
21
    {
22
        // this up() migration is auto-generated, please modify it to your needs
23
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
24
25
        $gatewaySchema = $this->container->getParameter('database_gateway_name');
26
        $this->addSql(sprintf(
27
            'ALTER TABLE %s.second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(255) NOT NULL',
28
            $gatewaySchema
29
        ));
30
    }
31
32
    public function down(Schema $schema)
33
    {
34
        // this down() migration is auto-generated, please modify it to your needs
35
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
36
37
        $gatewaySchema = $this->container->getParameter('database_gateway_name');
38
        $this->addSql(sprintf(
39
            'ALTER TABLE %s.second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(36) NOT NULL COLLATE utf8_unicode_ci',
40
            $gatewaySchema
41
        ));
42
    }
43
44
    public function setContainer(ContainerInterface $container = null)
45
    {
46
        $this->container = $container;
47
    }
48
}
49