| Conditions | 3 |
| Paths | 1 |
| Total Lines | 27 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | 2 | public static function build(): array |
|
| 18 | { |
||
| 19 | return [ |
||
| 20 | 1 | 'name' => 'updatePassword', |
|
| 21 | 1 | 'type' => Type::nonNull(Type::boolean()), |
|
| 22 | 1 | 'description' => 'Update the password for the user identified by the token. Return false if token is invalid', |
|
| 23 | 'args' => [ |
||
| 24 | 1 | 'token' => Type::nonNull(_types()->get(TokenType::class)), |
|
| 25 | 1 | 'password' => Type::nonNull(_types()->get(PasswordType::class)), |
|
| 26 | ], |
||
| 27 | 'resolve' => function ($root, array $args, SessionInterface $session): bool { |
||
|
1 ignored issue
–
show
|
|||
| 28 | /** @var UserRepository $repository */ |
||
| 29 | 2 | $repository = _em()->getRepository(User::class); |
|
| 30 | |||
| 31 | /** @var User $user */ |
||
| 32 | 2 | $repository->getAclFilter()->setEnabled(false); |
|
| 33 | 2 | $user = $repository->findOneByToken($args['token']); |
|
|
1 ignored issue
–
show
|
|||
| 34 | 2 | $repository->getAclFilter()->setEnabled(true); |
|
| 35 | |||
| 36 | 2 | if (!$user || !$user->isTokenValid()) { |
|
| 37 | 1 | return false; |
|
| 38 | } |
||
| 39 | |||
| 40 | 1 | $user->setPassword($args['password']); |
|
| 41 | 1 | _em()->flush(); |
|
| 42 | |||
| 43 | 1 | return true; |
|
| 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.