Passed
Push — master ( 31b9cb...154d5e )
by Nicolas
13:25
created

UserProcessor::postProcess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 2
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\DataFixtures\Processor;
6
7
use App\Entity\User;
8
use Fidry\AliceDataFixtures\ProcessorInterface;
9
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
10
11
final class UserProcessor implements ProcessorInterface
12
{
13
    private UserPasswordHasherInterface $userPasswordHasher;
14
15 2
    public function __construct(UserPasswordHasherInterface $userPasswordHasher)
16
    {
17 2
        $this->userPasswordHasher = $userPasswordHasher;
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23 2
    public function preProcess(string $id, object $object): void
24
    {
25 2
        if (!$object instanceof User) {
26 1
            return;
27
        }
28
29 1
        $object->setPassword($this->userPasswordHasher->hashPassword($object, $object->getPassword()));
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function postProcess(string $id, object $object): void
36
    {
37
        // nothing to do
38
    }
39
}
40