Completed
Push — master ( c7affe...8bcad0 )
by Anton
02:39
created

TestSeeder::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 0
1
<?php
2
3
use Phinx\Seed\AbstractSeed;
4
5
class TestSeeder extends AbstractSeed
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
    /**
8
     * Run Method.
9
     *
10
     * Write your database seeder using this method.
11
     *
12
     * More information on writing seeders is available here:
13
     * http://docs.phinx.org/en/latest/seeding.html
14
     */
15
    public function run()
16
    {
17
        $faker = Faker\Factory::create();
18
        $data = [];
19
        for ($i = 0; $i < 100; $i++) {
20
            $data[] = [
21
                'username'      => $faker->userName,
22
                'email'         => $faker->email,
23
                'status'        => array_rand(['active' => 1, 'disable' => 2, 'delete' => 3]),
24
                'created'       => date('Y-m-d H:i:s'),
25
            ];
26
        }
27
28
        $this->insert('test', $data);
29
    }
30
}
31