Completed
Pull Request — master (#28)
by
unknown
08:48 queued 04:19
created

LoadUserData::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 53
Code Lines 43

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 44
CRAP Score 1

Importance

Changes 5
Bugs 1 Features 2
Metric Value
c 5
b 1
f 2
dl 0
loc 53
ccs 44
cts 44
cp 1
rs 9.5797
cc 1
eloc 43
nc 1
nop 1
crap 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace SMG\UserBundle\DataFixtures\ORM;
4
5
use SMG\UserBundle\Entity\User;
6
use Doctrine\Common\DataFixtures\AbstractFixture;
7
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
8
use Doctrine\Common\Persistence\ObjectManager;
9
10
/**
11
 * Adds one Video without- and one Video with Comments.
12
 */
13
class LoadUserData extends AbstractFixture implements OrderedFixtureInterface
14
{
15 32
    public function load(ObjectManager $objectManager)
16
    {
17 32
        $u1 = new User();
18 32
        $u1->setUsername('allan');
19 32
        $u1->setEmail('[email protected]');
20 32
        $u1->setPlainPassword('plop');
21 32
        $u1->setRoles(array('ROLE_USER'));
22 32
        $u1->setConfirmationToken('123456');
23 32
        $u1->setEnabled(false);
24 32
        $u1->setLocked(true);
25
26 32
        $this->addReference('new-user', $u1);
27
28 32
        $u2 = new User();
29 32
        $u2->setUsername('Raphael');
30 32
        $u2->setEmail('[email protected]');
31 32
        $u2->setPlainPassword('plop');
32 32
        $u2->setRoles(array('ROLE_USER'));
33 32
        $u2->setPhoneNumber('123456789');
34 32
        $u2->setConfirmationToken('');
35 32
        $u2->setEnabled(true);
36 32
        $u2->setLocked(false);
37
38 32
        $this->addReference('user-without-confirmation-token', $u2);
39
40 32
        $u3 = new User();
41 32
        $u3->setUsername('Bobthesponge');
42 32
        $u3->setEmail('[email protected]');
43 32
        $u3->setPlainPassword('plop');
44 32
        $u3->setRoles(array('ROLE_USER'));
45 32
        $u3->setConfirmationToken('123456');
46 32
        $u3->setEnabled(true);
47 32
        $u3->setLocked(false);
48
49 32
        $this->addReference('user-with-confirmation-token', $u3);
50
51 32
        $u4 = new User();
52 32
        $u4->setUsername('admin');
53 32
        $u4->setEmail('[email protected]');
54 32
        $u4->setPlainPassword('admin');
55 32
        $u4->setRoles(['ROLE_ADMINPANEL']);
56 32
        $u4->setConfirmationToken('123456');
57 32
        $u4->setEnabled(true);
58 32
        $u4->setLocked(false);
59
60 32
        $this->addReference('admin', $u4);
61
62 32
        $objectManager->persist($u1);
63 32
        $objectManager->persist($u2);
64 32
        $objectManager->persist($u3);
65 32
        $objectManager->persist($u4);
66 32
        $objectManager->flush();
67 32
    }
68
69
    /**
70
     * load fixtures in ascending order.
71
     */
72 2
    public function getOrder()
73
    {
74 2
        return 1;
75
    }
76
}
77