BlockedTypeTableSeeder   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 74
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 67 4
1
<?php
2
3
namespace Database\Seeds;
4
5
use Illuminate\Database\Seeder;
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Seeder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use jeremykenedy\LaravelBlocker\App\Models\BlockedType;
7
8
class BlockedTypeTableSeeder extends Seeder
9
{
10
    /**
11
     * Run the database seeds.
12
     *
13
     * @return void
14
     */
15
    public function run()
16
    {
17
        /*
18
         * Blocked Types
19
         *
20
         */
21
        $BlockedTypes = [
22
            [
23
                'slug' => 'email',
24
                'name' => 'E-mail',
25
            ],
26
            [
27
                'slug' => 'ipAddress',
28
                'name' => 'IP Address',
29
            ],
30
            [
31
                'slug' => 'domain',
32
                'name' => 'Domain Name',
33
            ],
34
            [
35
                'slug' => 'user',
36
                'name' => 'User',
37
            ],
38
            [
39
                'slug' => 'city',
40
                'name' => 'City',
41
            ],
42
            [
43
                'slug' => 'state',
44
                'name' => 'State',
45
            ],
46
            [
47
                'slug' => 'country',
48
                'name' => 'Country',
49
            ],
50
            [
51
                'slug' => 'countryCode',
52
                'name' => 'Country Code',
53
            ],
54
            [
55
                'slug' => 'continent',
56
                'name' => 'Continent',
57
            ],
58
            [
59
                'slug' => 'region',
60
                'name' => 'Region',
61
            ],
62
        ];
63
64
        /*
65
         * Add Blocked Types
66
         *
67
         */
68
        if (config('laravelblocker.seedPublishedBlockedTypes')) {
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

68
        if (/** @scrutinizer ignore-call */ config('laravelblocker.seedPublishedBlockedTypes')) {
Loading history...
69
            foreach ($BlockedTypes as $BlockedType) {
70
                $newBlockedType = BlockedType::where('slug', '=', $BlockedType['slug'])
71
                    ->withTrashed()
72
                    ->first();
73
                if ($newBlockedType === null) {
74
                    $newBlockedType = BlockedType::create([
0 ignored issues
show
Unused Code introduced by
The assignment to $newBlockedType is dead and can be removed.
Loading history...
75
                        'slug' => $BlockedType['slug'],
76
                        'name' => $BlockedType['name'],
77
                    ]);
78
                }
79
            }
80
        }
81
        echo "\e[32mSeeding:\e[0m BlockedTypeTableSeeder\r\n";
82
    }
83
}
84