UserManager   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 32
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getSupport() 0 4 1
A preInsert() 0 6 2
A modifierLeMotDePasse() 0 5 1
1
<?php
2
3
namespace Starkerxp\UserBundle\Manager;
4
5
use Doctrine\ORM\EntityManager;
6
use Starkerxp\StructureBundle\Entity\AbstractEntity;
7
use Starkerxp\StructureBundle\Manager\AbstractManager;
8
use Starkerxp\UserBundle\Entity\User;
9
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoder;
10
11
class UserManager extends AbstractManager
12
{
13
    /**
14
     * @var UserPasswordEncoder
15
     */
16
    private $serviceEncoder;
17
18
    public function __construct(EntityManager $entityManager, $entity, $serviceEncoder)
19
    {
20
        parent::__construct($entityManager, $entity);
21
        $this->serviceEncoder = $serviceEncoder;
22
    }
23
24
    public function getSupport(AbstractEntity $object)
25
    {
26
        return $object instanceof User;
27
    }
28
29
    protected function preInsert(User $user)
30
    {
31
        if ($user->getPlainPassword()) {
32
            $this->modifierLeMotDePasse($user);
33
        }
34
    }
35
36
    private function modifierLeMotDePasse(User $user)
37
    {
38
        $motDePasse = $this->serviceEncoder->encodePassword($user, $user->getPlainPassword());
39
        $user->setPassword($motDePasse);
40
    }
41
42
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
43