Passed
Push — develop ( e1f02f...e3219b )
by Laurent
01:59
created

CreateUser::createUser()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 12
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the G.L.S.R. Apps package.
7
 *
8
 * (c) Dev-Int Création <[email protected]>.
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace User\Application\Factory;
15
16
use Core\Domain\Common\Model\VO\EmailField;
17
use Core\Domain\Common\Model\VO\NameField;
18
use Core\Domain\Common\Model\VO\ResourceUuid;
19
use Core\Domain\Protocol\Common\Command\CommandInterface;
20
use User\Domain\Model\User;
21
use User\Domain\Model\VO\Password;
22
23
class CreateUser
24
{
25
    public function createUser(CommandInterface $commandUser): User
26
    {
27
        $userUuid = null === $commandUser->uuid() ? ResourceUuid::generate() : ResourceUuid::fromString(
0 ignored issues
show
Bug introduced by
The method uuid() does not exist on Core\Domain\Protocol\Com...ommand\CommandInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Administration\Domain\Se...mmand\ConfigureSettings or Administration\Domain\Su...\Command\CreateSupplier. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
        $userUuid = null === $commandUser->/** @scrutinizer ignore-call */ uuid() ? ResourceUuid::generate() : ResourceUuid::fromString(
Loading history...
28
            $commandUser->uuid()
29
        );
30
31
        return User::create(
32
            $userUuid,
33
            NameField::fromString($commandUser->username()),
0 ignored issues
show
Bug introduced by
The method username() does not exist on Core\Domain\Protocol\Com...ommand\CommandInterface. It seems like you code against a sub-type of Core\Domain\Protocol\Com...ommand\CommandInterface such as User\Application\Command\AbstractUser. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
            NameField::fromString($commandUser->/** @scrutinizer ignore-call */ username()),
Loading history...
34
            EmailField::fromString($commandUser->email()),
0 ignored issues
show
Bug introduced by
The method email() does not exist on Core\Domain\Protocol\Com...ommand\CommandInterface. It seems like you code against a sub-type of Core\Domain\Protocol\Com...ommand\CommandInterface such as Administration\Domain\Su...\Command\CreateSupplier or Company\Application\Command\AbstractCompany or User\Application\Command\AbstractUser or Administration\Domain\Su...er\Command\EditSupplier. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
            EmailField::fromString($commandUser->/** @scrutinizer ignore-call */ email()),
Loading history...
35
            Password::fromString($commandUser->password()),
0 ignored issues
show
Bug introduced by
The method password() does not exist on Core\Domain\Protocol\Com...ommand\CommandInterface. It seems like you code against a sub-type of Core\Domain\Protocol\Com...ommand\CommandInterface such as User\Application\Command\AbstractUser. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
            Password::fromString($commandUser->/** @scrutinizer ignore-call */ password()),
Loading history...
36
            $commandUser->roles()
0 ignored issues
show
Bug introduced by
The method roles() does not exist on Core\Domain\Protocol\Com...ommand\CommandInterface. It seems like you code against a sub-type of Core\Domain\Protocol\Com...ommand\CommandInterface such as User\Application\Command\AbstractUser. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
            $commandUser->/** @scrutinizer ignore-call */ 
37
                          roles()
Loading history...
37
        );
38
    }
39
}
40