Passed
Push — chore/add-feature-tests ( 36c2df...e56562 )
by Bas
04:12 queued 19s
created

TaggablesSeeder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 61
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 54 2
1
<?php
2
3
namespace Database\Seeders;
4
5
use Illuminate\Database\Seeder;
6
use TestSetup\Models\Taggable;
7
8
class TaggablesSeeder extends Seeder
9
{
10
    /**
11
     * Run the database Seeds.
12
     *
13
     * @return void
14
     */
15
    public function run()
16
    {
17
        $taggables = '[
18
           {
19
              "tag_id":"A",
20
              "taggable_id":"winterfell",
21
              "taggable_type":"TestSetup\\\Models\\\Location"
22
           },
23
          {
24
              "tag_id":"S",
25
              "taggable_id":"beyond-the-wall",
26
              "taggable_type":"TestSetup\\\Models\\\Location"
27
           },
28
          {
29
              "tag_id":"E",
30
              "taggable_id":"PetyrBaelish",
31
              "taggable_type":"TestSetup\\\Models\\\Character"
32
           },
33
          {
34
              "tag_id":"F",
35
              "taggable_id":"PetyrBaelish",
36
              "taggable_type":"TestSetup\\\Models\\\Character"
37
           },
38
          {
39
              "tag_id":"G",
40
              "taggable_id":"PetyrBaelish",
41
              "taggable_type":"TestSetup\\\Models\\\Character"
42
           },
43
          {
44
              "tag_id":"A",
45
              "taggable_id":"SandorClegane",
46
              "taggable_type":"TestSetup\\\Models\\\Character"
47
           },
48
          {
49
              "tag_id":"F",
50
              "taggable_id":"SandorClegane",
51
              "taggable_type":"TestSetup\\\Models\\\Character"
52
           },
53
          {
54
              "tag_id":"K",
55
              "taggable_id":"SandorClegane",
56
              "taggable_type":"TestSetup\\\Models\\\Character"
57
           },
58
          {
59
              "tag_id":"P",
60
              "taggable_id":"SandorClegane",
61
              "taggable_type":"TestSetup\\\Models\\\Character"
62
           }
63
        ]';
64
65
        $taggables = json_decode($taggables, JSON_OBJECT_AS_ARRAY);
0 ignored issues
show
Bug introduced by
Database\Seeders\JSON_OBJECT_AS_ARRAY of type integer is incompatible with the type boolean|null expected by parameter $associative of json_decode(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

65
        $taggables = json_decode($taggables, /** @scrutinizer ignore-type */ JSON_OBJECT_AS_ARRAY);
Loading history...
66
67
        foreach ($taggables as $taggable) {
68
            Taggable::insertOrIgnore($taggable);
69
        }
70
    }
71
}
72