Completed
Push — 1.4-password-hashing ( c4872d )
by Kamil
11:17
created

UserWithEncoderFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A createNew() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Sylius\Bundle\UserBundle\Factory;
6
7
use Sylius\Component\Resource\Factory\FactoryInterface;
8
use Sylius\Component\User\Model\UserInterface;
9
10
final class UserWithEncoderFactory implements FactoryInterface
11
{
12
    /** @var FactoryInterface */
13
    private $decoratedUserFactory;
14
15
    /** @var string */
16
    private $encoderName;
17
18
    public function __construct(FactoryInterface $decoratedUserFactory, string $encoderName)
19
    {
20
        $this->decoratedUserFactory = $decoratedUserFactory;
21
        $this->encoderName = $encoderName;
22
    }
23
24
    public function createNew(): UserInterface
25
    {
26
        /** @var UserInterface $user */
27
        $user = $this->decoratedUserFactory->createNew();
28
29
        $user->setEncoderName($this->encoderName);
30
31
        return $user;
32
    }
33
}
34