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 |
||
| 9 | View Code Duplication | class Revoke |
|
| 10 | {
|
||
| 11 | const ROUTE = '/revoke'; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * The slim framework application instance. |
||
| 15 | * |
||
| 16 | * @var Slim |
||
| 17 | */ |
||
| 18 | private $slim; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * The oauth2 server instance. |
||
| 22 | * |
||
| 23 | * @var OAuth2\Server |
||
| 24 | */ |
||
| 25 | private $server; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Construct a new instance of Authorize. |
||
| 29 | * |
||
| 30 | * @param Slim $slim The slim framework application instance. |
||
| 31 | * @param OAuth2\Server $server The oauth2 server imstance. |
||
| 32 | */ |
||
| 33 | public function __construct(Slim $slim, OAuth2\Server $server) |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Call this class as a function. |
||
| 41 | * |
||
| 42 | * @return void |
||
| 43 | */ |
||
| 44 | public function __invoke() |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Register this route with the given Slim application and OAuth2 server |
||
| 55 | * |
||
| 56 | * @param Slim $slim The slim framework application instance. |
||
| 57 | * @param OAuth2\Server $server The oauth2 server instance. |
||
| 58 | * |
||
| 59 | * @return void |
||
| 60 | */ |
||
| 61 | public static function register(Slim $slim, OAuth2\Server $server) |
||
| 65 | } |
||
| 66 |