UpdateUserHandler::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace SumoCoders\FrameworkMultiUserBundle\Command;
4
5
use SumoCoders\FrameworkMultiUserBundle\DataTransferObject\Interfaces\UserDataTransferObject;
6
use SumoCoders\FrameworkMultiUserBundle\User\BaseUserRepositoryCollection;
7
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
8
9 View Code Duplication
final class UpdateUserHandler extends AbstractUserHandler
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    /** @var BaseUserRepositoryCollection */
12
    private $userRepositoryCollection;
13
14
    /** @var EncoderFactoryInterface */
15
    private $encoderFactory;
16
17
    public function __construct(
18
        EncoderFactoryInterface $encoderFactory,
19
        BaseUserRepositoryCollection $userRepositoryCollection
20
    ) {
21
        $this->userRepositoryCollection = $userRepositoryCollection;
22
        $this->encoderFactory = $encoderFactory;
23
    }
24
25
    public function handle(UserDataTransferObject $userDataTransferObject): void
26
    {
27
        $userEntity = $userDataTransferObject->getEntity();
28
29
        $userEntity->encodePassword($this->encoderFactory->getEncoder($userEntity));
30
        $repository = $this->getUserRepositoryForUser($this->userRepositoryCollection, $userEntity);
31
        $repository->save($userEntity);
32
    }
33
}
34