Completed
Push — sf2.7 ( 18de34...b252b6 )
by Laurent
18:26
created

UserFixtures::load()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 25
rs 8.8571
cc 1
eloc 10
nc 1
nop 1
1
<?php 
2
namespace AppBundle\DataFixtures\ORM;
3
4
use Doctrine\Common\Persistence\ObjectManager;
5
use Doctrine\Common\DataFixtures\AbstractFixture;
6
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
7
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8
use Symfony\Component\DependencyInjection\ContainerInterface;
9
//use AppBundle\Entity\User;
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
10
//use AppBundle\Entity\Group;
11
12
class UserFixtures extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
13
{
14
    /** * @var ContainerInterface */
15
    private $container;
16
    /** * {@inheritDoc} */
17
    public function setContainer(ContainerInterface $container = null)
18
    {
19
        $this->container = $container;
20
    }
21
     
22
    public function getOrder() {
23
        return 0;
24
    }
25
 
26
    public function load(ObjectManager $manager) {
27
 
28
        $userManager = $this->container->get('fos_user.user_manager');
29
         
30
        $user = $userManager->createUser();
31
         
32
        $user
33
            ->setUsername('someguy')
34
            ->setEmail('[email protected]')
35
            ->setFirstLogin(\DateTime::createFromFormat('j-M-Y', '15-Feb-2009'))
36
            ->setEnabled(true);
37
         
38
        $user->setPlainPassword('somepass');
39
 
40
        // Equivalent à :
41
         
42
//        $encoder = $this->container
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
43
//                ->get('security.encoder_factory')
44
//                ->getEncoder($user)
45
//            ;
46
//        $user->setPassword($encoder->encodePassword('somepass', $user->getSalt()));
47
 
48
         
49
        $userManager->updateUser($user);
50
    }     
51
}