| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Lines | 17 |
| Ratio | 100 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | public function loadUserByUsername($user) |
||
| 18 | { |
||
| 19 | try { |
||
| 20 | // SecurityContext always tries to authenticate anonymous users when checking granted access. |
||
| 21 | // In that case $user is an instance of \eZ\Publish\Core\MVC\Symfony\Security\User. |
||
| 22 | // We don't need to reload the user here. |
||
| 23 | if ($user instanceof UserInterface) { |
||
| 24 | return $user; |
||
| 25 | } |
||
| 26 | |||
| 27 | return $this->createSecurityUser( |
||
| 28 | $this->userService->loadUserByEmail($user) |
||
| 29 | ); |
||
| 30 | } catch (NotFoundException $e) { |
||
| 31 | throw new UsernameNotFoundException($e->getMessage(), 0, $e); |
||
| 32 | } |
||
| 33 | } |
||
| 34 | } |
||
| 35 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.