Conditions | 3 |
Paths | 3 |
Total Lines | 23 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
33 | public function __invoke(RemoveOwnerToOrganizationCommand $command) |
||
34 | { |
||
35 | $organization = $this->repository->organizationOfId( |
||
36 | OrganizationId::generate( |
||
37 | $command->organizationId() |
||
38 | ) |
||
39 | ); |
||
40 | if (!$organization instanceof Organization) { |
||
41 | throw new OrganizationDoesNotExistException(); |
||
42 | } |
||
43 | |||
44 | if (!$organization->isOwner(UserId::generate($command->removerId()))) { |
||
45 | throw new UnauthorizedOrganizationActionException(); |
||
46 | } |
||
47 | |||
48 | $organization->removeOwner( |
||
49 | UserId::generate( |
||
50 | $command->userId() |
||
51 | ) |
||
52 | ); |
||
53 | |||
54 | $this->repository->persist($organization); |
||
55 | } |
||
56 | } |
||
57 |