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 |
||
| 23 | class FluentRefreshToken extends AbstractFluentAdapter implements RefreshTokenInterface |
||
| 24 | { |
||
| 25 | /** |
||
| 26 | * Return a new instance of \League\OAuth2\Server\Entity\RefreshTokenEntity. |
||
| 27 | * |
||
| 28 | * @param string $token |
||
| 29 | * |
||
| 30 | * @return \League\OAuth2\Server\Entity\RefreshTokenEntity |
||
|
|
|||
| 31 | */ |
||
| 32 | 9 | View Code Duplication | public function get($token) |
| 48 | |||
| 49 | /** |
||
| 50 | * Create a new refresh token_name. |
||
| 51 | * |
||
| 52 | * @param string $token |
||
| 53 | * @param int $expireTime |
||
| 54 | * @param string $accessToken |
||
| 55 | * |
||
| 56 | * @return \League\OAuth2\Server\Entity\RefreshTokenEntity |
||
| 57 | */ |
||
| 58 | 3 | View Code Duplication | public function create($token, $expireTime, $accessToken) |
| 73 | |||
| 74 | /** |
||
| 75 | * Delete the refresh token. |
||
| 76 | * |
||
| 77 | * @param \League\OAuth2\Server\Entity\RefreshTokenEntity $token |
||
| 78 | * |
||
| 79 | * @return void |
||
| 80 | */ |
||
| 81 | 3 | public function delete(RefreshTokenEntity $token) |
|
| 87 | } |
||
| 88 |
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.