Completed
Push — 1.10.x ( 2635b5...f0080b )
by Yannick
165:55 queued 120:08
created

Version20150813200000   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 60
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 60
loc 60
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 3

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
/* For licensing terms, see /license.txt */
3
4
namespace Application\Migrations\Schema\V110;
5
6
use Application\Migrations\AbstractMigrationChamilo;
7
use Doctrine\DBAL\Schema\Schema;
8
9
/**
10
 * Calendar color
11
 */
12
class Version20150813200000 extends AbstractMigrationChamilo
13
{
14
    /**
15
     * @param Schema $schema
16
     */
17
    public function up(Schema $schema)
18
    {
19
        $entityManage = $this->getEntityManager();
20
21
        $deleteOptions = $entityManage->createQueryBuilder();
22
        $deleteSettings = $entityManage->createQueryBuilder();
23
24
        $deleteOptions->delete('ChamiloCoreBundle:SettingsOptions', 'o')
25
            ->andWhere(
26
                $deleteOptions->expr()->in(
27
                    'o.variable',
28
                    [
29
                        'math_mimetex'
30
                    ]
31
                )
32
            );
33
        $deleteOptions->getQuery()->execute();
34
35
        $deleteSettings->delete('ChamiloCoreBundle:SettingsCurrent', 's')
36
            ->andWhere(
37
                $deleteSettings->expr()->in(
38
                    's.variable',
39
                    [
40
                        'math_mimetex'
41
                    ]
42
                )
43
            );
44
        $deleteSettings->getQuery()->execute();
45
    }
46
47
    /**
48
     * @param Schema $schema
49
     */
50
    public function down(Schema $schema)
51
    {
52
        $this->addSettingCurrent(
53
            'math_mimetex',
54
            null,
55
            'radio',
56
            'Editor',
57
            'false',
58
            'MathMimetexTitle',
59
            'MathMimetexComment',
60
            null,
61
            null,
62
            1,
63
            false,
64
            true,
65
            [
66
                0 => ['value' => 'true', 'text' => 'Yes'],
67
                1 => ['value' => 'false', 'text' => 'No']
68
            ]
69
        );
70
    }
71
}
72