| Conditions | 1 |
| Paths | 1 |
| Total Lines | 28 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | 1 | public static function build(): array |
|
| 17 | { |
||
| 18 | return [ |
||
| 19 | 1 | 'name' => 'leaveFamily', |
|
| 20 | 1 | 'type' => Type::nonNull(_types()->getOutput(User::class)), |
|
| 21 | 1 | 'description' => 'Make the given user independent from his family and inactive.', |
|
| 22 | 'args' => [ |
||
| 23 | 1 | 'id' => Type::nonNull(_types()->getId(User::class)), |
|
| 24 | ], |
||
| 25 | 'resolve' => function ($root, array $args, SessionInterface $session): User { |
||
|
1 ignored issue
–
show
|
|||
| 26 | /** @var User $user */ |
||
| 27 | 1 | $user = $args['id']->getEntity(); |
|
| 28 | |||
| 29 | // Check ACL |
||
| 30 | 1 | Helper::throwIfDenied($user, 'update'); |
|
| 31 | |||
| 32 | // Set owner while pretending we are an admin to workaround normal security things |
||
| 33 | 1 | $previousCurrentUser = User::getCurrent(); |
|
| 34 | 1 | User::setCurrent(new User(User::ROLE_ADMINISTRATOR)); |
|
| 35 | 1 | $user->setOwner($user); |
|
| 36 | 1 | User::setCurrent($previousCurrentUser); |
|
| 37 | |||
| 38 | 1 | $user->setFamilyRelationship(RelationshipType::HOUSEHOLDER); |
|
| 39 | 1 | $user->setStatus(User::STATUS_INACTIVE); |
|
| 40 | |||
| 41 | 1 | _em()->flush(); |
|
| 42 | |||
| 43 | 1 | return $user; |
|
| 44 | 1 | }, |
|
| 48 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.