UserProcessor   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 32
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A preProcess() 0 7 2
A postProcess() 0 2 1
1
<?php
2
3
namespace Smart\AuthenticationBundle\DataFixtures\Processor;
4
5
use Fidry\AliceDataFixtures\ProcessorInterface;
6
use Smart\AuthenticationBundle\Security\SmartUserInterface;
7
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
8
9
/**
10
 * Nicolas Bastien <[email protected]>
11
 */
12
class UserProcessor implements ProcessorInterface
13
{
14
    /**
15
     * @var UserPasswordEncoderInterface
16
     */
17
    private $encoder;
18
19
    /**
20
     * @param UserPasswordEncoderInterface $encoder
21
     */
22
    public function __construct(UserPasswordEncoderInterface $encoder)
23
    {
24
        $this->encoder = $encoder;
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function preProcess(string $fixtureId, $object): void
31
    {
32
        if (!$object instanceof SmartUserInterface) {
33
            return;
34
        }
35
36
        $object->setPassword($this->encoder->encodePassword($object, $object->getPlainPassword()));
37
    }
38
39
    /**
40
     * @inheritdoc
41
     */
42
    public function postProcess(string $fixtureId, $object): void
43
    {
44
    }
45
}
46