UserProcessor::preProcess()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 7
rs 10
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