UserService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 34
ccs 0
cts 21
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fillUserDTO() 0 9 1
A getCommand() 0 10 1
1
<?php
2
namespace App\Service;
3
4
use App\Entity\User;
5
use App\DTO\UserDTO;
6
use App\Command\CommandInterface;
7
use App\Command\CreateUserCommand;
8
use App\Command\UpdateUserCommand;
9
use Ramsey\Uuid\Uuid;
10
use App\Traits\CommandInstanceTrait;
11
12
class UserService
13
{
14
    use CommandInstanceTrait;
15
16
    /**
17
     * @param User $user
18
     * @return UserDTO
19
     */
20
    public function fillUserDTO(User $user): UserDTO
21
    {
22
        return new UserDTO(
23
            $user->getId()->toString(),
24
            $user->getFirstName(),
25
            $user->getLastName(),
26
            $user->getEmail(),
27
            $user->getStatus(),
28
            $user->getPlainPassword()
29
        );
30
    }
31
32
    /**
33
     * @param UserDTO $userDTO
34
     * @return CreateUserCommand|UpdateUserCommand
35
     */
36
    public function getCommand(UserDTO $userDTO):  CommandInterface
37
    {
38
        $command = $this->getCommandInstance($loanDTO->getId(), 'User');
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $loanDTO seems to be never defined.
Loading history...
39
        return $command->newInstanceArgs([
40
            $userDTO->getId() ?? Uuid::uuid4(),
41
            $userDTO->getFirstName(),
42
            $userDTO->getLastName(),
43
            $userDTO->getEmail(),
44
            $userDTO->getStatus(),
45
            $userDTO->getPlainPassword()
46
        ]);
47
    }
48
}