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

Version20150812230500   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 62
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 62
loc 62
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
 * Class Version20150812230500
11
 *
12
 * @package Application\Migrations\Schema\V11010
13
 */
14
class Version20150812230500 extends AbstractMigrationChamilo
15
{
16
17
    /**
18
     * @param Schema $schema
19
     */
20
    public function up(Schema $schema)
21
    {
22
        $this->addSettingCurrent(
23
            'allow_coach_feedback_exercises',
24
            null,
25
            'radio',
26
            'Session',
27
            'false',
28
            'AllowCoachFeedbackExercisesTitle',
29
            'AllowCoachFeedbackExercisesComment',
30
            null,
31
            null,
32
            1,
33
            true,
34
            false,
35
            [
36
                ['value' => 'true', 'text' => 'Yes'],
37
                ['value' => 'false', 'text' => 'No']
38
            ]
39
        );
40
    }
41
42
    /**
43
     * @param Schema $schema
44
     */
45
    public function down(Schema $schema)
46
    {
47
        $entityManage = $this->getEntityManager();
48
49
        $deleteOptions = $entityManage->createQueryBuilder();
50
51
        $deleteOptions->delete('ChamiloCoreBundle:SettingsOptions', 'o')
52
            ->andWhere(
53
                $deleteOptions->expr()->in(
54
                    'o.variable',
55
                    [
56
                        'allow_coach_feedback_exercises'
57
                    ]
58
                )
59
            );
60
        $deleteOptions->getQuery()->execute();
61
62
        $deleteSettings = $entityManage->createQueryBuilder();
63
        $deleteSettings->delete('ChamiloCoreBundle:SettingsCurrent', 's')
64
            ->andWhere(
65
                $deleteSettings->expr()->in(
66
                    's.variable',
67
                    [
68
                        'allow_coach_feedback_exercises'
69
                    ]
70
                )
71
            );
72
        $deleteSettings->getQuery()->execute();
73
    }
74
75
}
76