Issues (62)

src/Service/UserService.php (1 issue)

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
}