Passed
Push — master ( f762ef...190e8a )
by Julito
09:11
created

Version20150803163400::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 52
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 40
nc 1
nop 1
dl 0
loc 52
rs 9.28
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CoreBundle\Migrations\Schema\V110;
5
6
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
7
use Doctrine\DBAL\Schema\Schema;
8
9
/**
10
 * Class Version20150803163400
11
 *
12
 * @package Chamilo\CoreBundle\Migrations\Schema\V110
13
 */
14
class Version20150803163400 extends AbstractMigrationChamilo
15
{
16
    /**
17
     * @param Schema $schema
18
     */
19
    public function up(Schema $schema)
20
    {
21
        $this->addSettingCurrent(
22
            'cron_remind_course_expiration_activate',
23
            null,
24
            'radio',
25
            'Crons',
26
            'false',
27
            'CronRemindCourseExpirationActivateTitle',
28
            'CronRemindCourseExpirationActivateComment',
29
            null,
30
            null,
31
            1,
32
            true,
33
            false,
34
            [
35
                0 => ['value' => 'true', 'text' => 'Yes'],
36
                1 => ['value' => 'false', 'text' => 'No']
37
            ]
38
        );
39
40
        $this->addSettingCurrent(
41
            'cron_remind_course_expiration_frequency',
42
            null,
43
            'textfield',
44
            'Crons',
45
            '2',
46
            'CronRemindCourseExpirationFrecuenqyTitle',
47
            'CronRemindCourseExpirationFrecuenqyComment',
48
            null,
49
            null,
50
            1,
51
            true,
52
            false
53
        );
54
55
        $this->addSettingCurrent(
56
            'cron_course_finished_activate',
57
            null,
58
            'radio',
59
            'Crons',
60
            'false',
61
            'CronCourseFinishedActivateTitle',
62
            'CronCourseFinishedActivateComment',
63
            null,
64
            null,
65
            1,
66
            true,
67
            false,
68
            [
69
                0 => ['value' => 'true', 'text' => 'Yes'],
70
                1 => ['value' => 'false', 'text' => 'No']
71
            ]
72
        );
73
    }
74
75
    /**
76
     * @param Schema $schema
77
     */
78
    public function down(Schema $schema)
79
    {
80
        $entityManage = $this->getEntityManager();
81
82
        $deleteOptions = $entityManage->createQueryBuilder();
83
84
        $deleteOptions->delete('ChamiloCoreBundle:SettingsOptions', 'o')
85
            ->andWhere(
86
                $deleteOptions->expr()->in(
87
                    'o.variable',
88
                    [
89
                        'cron_remind_course_expiration_activate',
90
                        'cron_course_finished_activate'
91
                    ]
92
                )
93
            );
94
        $deleteOptions->getQuery()->execute();
95
96
        $deleteSettings = $entityManage->createQueryBuilder();
97
        $deleteSettings->delete('ChamiloCoreBundle:SettingsCurrent', 's')
98
            ->andWhere(
99
                $deleteSettings->expr()->in(
100
                    's.variable',
101
                    [
102
                        'cron_remind_course_expiration_activate',
103
                        'cron_remind_course_expiration_frequency',
104
                        'cron_course_finished_activate'
105
                    ]
106
                )
107
            );
108
        $deleteSettings->getQuery()->execute();
109
    }
110
111
}
112