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

RemoveUser::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
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\Infrastructure\Storage;
15
16
use Core\Domain\Common\Model\VO\ResourceUuid;
17
use User\Domain\Exception\UserNotFoundException;
18
use User\Domain\Storage\RemoveUser as RemoveUserDomain;
19
use User\Infrastructure\Doctrine\Entity\User;
20
use User\Infrastructure\Doctrine\Repository\UserRepository;
21
22
class RemoveUser implements RemoveUserDomain
23
{
24
    private UserRepository $userRepository;
25
26
    public function __construct(UserRepository $userRepository)
27
    {
28
        $this->userRepository = $userRepository;
29
    }
30
31
    public function remove(string $uuid): void
32
    {
33
        $user = $this->userRepository->findOneByUuid(ResourceUuid::fromString($uuid)->__toString());
34
35
        if (!$user instanceof User) {
36
            throw new UserNotFoundException();
37
        }
38
39
        $this->userRepository->remove($user);
40
    }
41
}
42