Passed
Branch master (4ff80c)
by Matt
14:34
created

QuestionsChoicesTableSeeder::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 66
Code Lines 38

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 38
nc 1
nop 0
dl 0
loc 66
rs 9.3191
c 1
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
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
        ]);
81
    }
82
}
83