User::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 1
1
<?php
2
use Doctrine\Common\DataFixtures\AbstractFixture;
3
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
4
use Doctrine\Common\Persistence\ObjectManager;
5
use User\Entity\User as UserModel;
6
7
/**
8
 *
9
 * @author Thiago Paes <[email protected]>
10
 */
11
class User extends AbstractFixture implements OrderedFixtureInterface
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...
12
{
13
    /**
14
     * Loader
15
     *
16
     * @param ObjectManager $manager
17
     */
18
    public function load(ObjectManager $manager)
19
    {
20
        $i      = 1;
21
        $user   = [
22
            'name' => 'User ' . $i,
23
            'email' => 'user' . $i . '@users.net',
24
        ];
25
26
        $obj = new UserModel();
27
        $obj->setName($user['name']);
28
        $obj->setEmail($user['email']);
29
30
        $manager->persist($obj);
31
        $manager->flush();
32
33
        $this->addReference('user_' . $i, $obj);
34
    }
35
36
    /**
37
     * Load order
38
     *
39
     * @return int
40
     */
41
    public function getOrder()
42
    {
43
        return 1;
44
    }
45
}
46