Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 17 | class RemoteUser implements UserProviderInterface, RemoteUserProviderInterface |
||
| 18 | { |
||
| 19 | protected $logger; |
||
| 20 | protected $eZUserProvider; |
||
| 21 | protected $handlerMap; |
||
| 22 | protected $container; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param APIUserProviderInterface $eZUserProvider the user provider to which we actually delegate finding eZ User |
||
| 26 | * @param array $handlerMap |
||
| 27 | */ |
||
| 28 | public function __construct(APIUserProviderInterface $eZUserProvider, array $handlerMap, $container) |
||
| 34 | |||
| 35 | public function setLogger(LoggerInterface $logger) |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @todo throw an exception ? |
||
| 42 | * @param $username |
||
| 43 | * @return UserInterface |
||
| 44 | */ |
||
| 45 | public function loadUserByUsername($username) |
||
| 48 | |||
| 49 | /** |
||
| 50 | * This method is called *on every page after the user logged in*. |
||
| 51 | * We do not want to call the remote ws on every page. |
||
| 52 | * We 'might' check in the eZ db if the user is still there and/or enabled, BUT even that might be unnecessary, as |
||
| 53 | * the remoteuser gets converted to an ezmvcuser by the listener, which means this is only called upon login? |
||
| 54 | * |
||
| 55 | * @param UserInterface $user |
||
| 56 | * @return UserInterface |
||
| 57 | */ |
||
| 58 | public function refreshUser(UserInterface $user) |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Whether this provider supports the given user class. |
||
| 71 | * |
||
| 72 | * @param string $class |
||
| 73 | * |
||
| 74 | * @return bool |
||
| 75 | */ |
||
| 76 | public function supportsClass($class) |
||
| 81 | |||
| 82 | public function loadAPIUserByRemoteUser(KaliopRemoteUser $remoteUser) |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @param KaliopRemoteUser $remoteUser |
||
| 120 | * @return RemoteUserHandlerInterface |
||
| 121 | * @throws \Exception |
||
| 122 | */ |
||
| 123 | View Code Duplication | protected function getHandler($remoteUser) |
|
| 131 | |||
| 132 | /** |
||
| 133 | * A courtesy method, if some other service wants to retrieve a remote-user handler for a given php class. |
||
| 134 | * Useful to retrieve the remote-user handler before the actual creation of the actual remote-user object, which |
||
| 135 | * allows f.e. to put in the remote-user handler some validation code |
||
| 136 | * |
||
| 137 | * @param string $class a php class name |
||
| 138 | * @return RemoteUserHandlerInterface |
||
| 139 | * @throws \Exception |
||
| 140 | */ |
||
| 141 | View Code Duplication | public function getHandlerForClass($class) |
|
| 148 | } |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.