UsersSeeder::run()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 14
rs 10
1
<?php
2
3
namespace Database\Seeders;
4
5
use Illuminate\Database\Seeder;
6
use LaravelFreelancerNL\Aranguent\Auth\User;
7
8
class UsersSeeder extends Seeder
9
{
10
    /**
11
     * Run the database Seeds.
12
     *
13
     * @return void
14
     */
15
    public function run()
16
    {
17
        $users = '[
18
           {
19
              "_key":"LyannaStark",
20
              "username":"Lyanna Stark",
21
              "email":"[email protected]"
22
           }
23
        ]';
24
25
        $users = json_decode($users, 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

25
        $users = json_decode($users, /** @scrutinizer ignore-type */ JSON_OBJECT_AS_ARRAY);
Loading history...
26
27
        foreach ($users as $user) {
28
            User::insertOrIgnore($user);
29
        }
30
    }
31
}
32