Completed
Push — master ( 850b1f...5a9157 )
by Valentyn
04:43
created

UsersFixtures::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 7
nc 1
nop 1
1
<?php
2
3
namespace App\DataFixtures;
4
5
use App\Entity\User;
6
use Doctrine\Bundle\FixturesBundle\Fixture;
7
use Doctrine\Common\Persistence\ObjectManager;
8
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
9
10
class UsersFixtures extends Fixture
11
{
12
    private $encoder;
13
14
    public function __construct(UserPasswordEncoderInterface $encoder)
15
    {
16
        $this->encoder = $encoder;
17
    }
18
19
    public function load(ObjectManager $manager)
20
    {
21
        $user = new User();
22
        $user->username = 'tester_fixture';
23
        $user->email = '[email protected]';
24
        $user->setPassword('123456', $this->encoder);
25
        $manager->persist($user);
26
        $manager->flush();
27
    }
28
}