Completed
Push — feature/test-php-7-2-in-travis ( 027341...a56bae )
by
unknown
05:31
created

Version20150522164907   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 43
loc 43
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setContainer() 4 4 1
A up() 9 9 1
A down() 9 9 1
A getGatewaySchema() 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\StepupMiddleware\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 Version20150522164907 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 ContainerInterface
17
     */
18
    private $container;
19
20
    public function setContainer(ContainerInterface $container = null)
21
    {
22
        $this->container = $container;
23
    }
24
25
    /**
26
     * @param Schema $schema
27
     */
28
    public function up(Schema $schema)
29
    {
30
        $gatewaySchema = $this->getGatewaySchema();
31
32
        // this up() migration is auto-generated, please modify it to your needs
33
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
34
35
        $this->addSql(sprintf('CREATE UNIQUE INDEX unq_saml_entity_entity_id_type ON %s.saml_entity (entity_id, type)', $gatewaySchema));
36
    }
37
38
    /**
39
     * @param Schema $schema
40
     */
41
    public function down(Schema $schema)
42
    {
43
        $gatewaySchema = $this->getGatewaySchema();
44
45
        // this down() migration is auto-generated, please modify it to your needs
46
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
47
48
        $this->addSql(sprintf('DROP INDEX unq_saml_entity_entity_id_type ON %s.saml_entity', $gatewaySchema));
49
    }
50
51
    private function getGatewaySchema()
52
    {
53
        return $this->container->getParameter('database_gateway_name');
54
    }
55
}
56