Completed
Pull Request — master (#10)
by
unknown
03:16
created

CreateUserHandler::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 7
Ratio 70 %

Importance

Changes 4
Bugs 1 Features 1
Metric Value
c 4
b 1
f 1
dl 7
loc 10
rs 9.4285
cc 1
eloc 7
nc 1
nop 2
1
<?php
2
3
namespace SumoCoders\FrameworkMultiUserBundle\Command;
4
5
use SumoCoders\FrameworkMultiUserBundle\User\UserRepositoryCollection;
6
7 View Code Duplication
final class CreateUserHandler extends UserHandler
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...
8
{
9
    /**
10
     * @var UserRepositoryCollection
11
     */
12
    private $userRepositoryCollection;
13
14
    /**
15
     * CreateUserHandler constructor.
16
     *
17
     * @param UserRepositoryCollection $userRepositoryCollection
18
     */
19
    public function __construct(UserRepositoryCollection $userRepositoryCollection)
20
    {
21
        $this->userRepositoryCollection = $userRepositoryCollection;
22
    }
23
24
    /**
25
     * @param CreateUser $command
26
     */
27
    public function handle(CreateUser $command, $class)
28
    {
29
        $user = new $class(
30
            $command->getUsername(),
31
            $command->getPassword(),
32
            $command->getDisplayName()
33
        );
34
        $repository = $this->getUserRepositoryForUser($this->userRepositoryCollection, $user);
35
        $repository->add($user);
36
    }
37
}
38