Passed
Push — master ( b73b0e...19e997 )
by UP805717
12:48
created

QuestionsChoicesTableSeeder::run()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 129
Code Lines 74

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 74
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 129
rs 8.2857

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
3
use Illuminate\Database\Seeder;
4
5
class QuestionsChoicesTableSeeder extends Seeder
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
{
7
    private $table = 'question_choices';
8
    /**
9
     * Run the database seeds.
10
     *
11
     * @return void
12
     */
13
    public function run()
14
    {
15
        DB::table($this->table)->truncate();
16
        DB::table($this->table)->insert([
17
            // Choices for question 1
18
        [
19
            'question_id' => 1,
20
            'is_right_choice' => '0',
21
            'choice' => 'A pineapple tree with cucumbers'
22
        ],
23
        [
24
            'question_id' => 1,
25
            'is_right_choice' => '1', // this is the right choice (enum = 1 = true, enum = 0 = false)
26
            'choice' => 'A binary search tree'
27
        ],
28
        [
29
            'question_id' => 1,
30
            'is_right_choice' => '0',
31
            'choice' => 'A church choir'
32
        ],
33
        [
34
            'question_id' => 1,
35
            'is_right_choice' => '0',
36
            'choice' => 'A logarithmic skip line'
37
        ],
38
            // Choices for question 2
39
        [
40
            'question_id' => 2,
41
            'is_right_choice' => '0',
42
            'choice' => '{A, B, C, D, E, F, G}'
43
        ],
44
        [
45
            'question_id' => 2,
46
            'is_right_choice' => '0',
47
            'choice' => '{{1, 0.5, 18, 2.2, 1.8, 89, 45}, 2, 4, 8}'
48
        ],
49
        [
50
            'question_id' => 2,
51
            'is_right_choice' => '0',
52
            'choice' => '{-1, -2, -3, {-8, -12, -89}, 2, 1}'
53
        ],
54
        [
55
            'question_id' => 2,
56
            'is_right_choice' => '1', // this is the right answer again (hi)
57
            'choice' => '{1, 34, 56, {50, 67, 123, 978}, 54, 12, 17}'
58
        ],
59
            // Choices for question 3
60
        [
61
            'question_id' => 3,
62
            'is_right_choice' => '1', // this is also right answer...last time
63
            'choice' => 'Violet'
64
        ],
65
        [
66
            'question_id' => 3,
67
            'is_right_choice' => '0',
68
            'choice' => 'Cheeky Cherry'
69
        ],
70
        [
71
            'question_id' => 3,
72
            'is_right_choice' => '0',
73
            'choice' => 'Racing Green'
74
        ],
75
        [
76
            'question_id' => 3,
77
            'is_right_choice' => '0',
78
            'choice' => 'Saucy Strawberry'
79
        ],
80
        // Choices for question 4
81
        [
82
            'question_id' => 4,
83
            'is_right_choice' => '1', // this is also right answer...last time
84
            'choice' => 'Hopefully'
85
        ],
86
        [
87
            'question_id' => 4,
88
            'is_right_choice' => '0',
89
            'choice' => 'No'
90
        ],
91
        [
92
            'question_id' => 4,
93
            'is_right_choice' => '0',
94
            'choice' => 'A million percent yes!'
95
        ],
96
        [
97
            'question_id' => 4,
98
            'is_right_choice' => '0',
99
            'choice' => 'Who knows?'
100
        ],
101
        // Choices for question 5
102
        [
103
            'question_id' => 5,
104
            'is_right_choice' => '0', // this is also right answer...last time
105
            'choice' => '2010'
106
        ],
107
        [
108
            'question_id' => 5,
109
            'is_right_choice' => '0',
110
            'choice' => '2012'
111
        ],
112
        [
113
            'question_id' => 5,
114
            'is_right_choice' => '1',
115
            'choice' => '2008'
116
        ],
117
        [
118
            'question_id' => 5,
119
            'is_right_choice' => '0',
120
            'choice' => '2003'
121
        ],
122
        // Choices for question 6
123
        [
124
            'question_id' => 6,
125
            'is_right_choice' => '0', // this is also right answer...last time
126
            'choice' => 'No'
127
        ],
128
        [
129
            'question_id' => 6,
130
            'is_right_choice' => '0',
131
            'choice' => 'Whats even is No-brainer?'
132
        ],
133
        [
134
            'question_id' => 6,
135
            'is_right_choice' => '0',
136
            'choice' => 'Possibly'
137
        ],
138
        [
139
            'question_id' => 6,
140
            'is_right_choice' => '1',
141
            'choice' => 'Yes'
142
        ]
143
        ]);
144
    }
145
}
146