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 |
||
| 13 | View Code Duplication | class Revoke |
|
| 14 | {
|
||
| 15 | const ROUTE = '/revoke'; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * The slim framework application instance. |
||
| 19 | * |
||
| 20 | * @var Slim |
||
| 21 | */ |
||
| 22 | private $slim; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * The oauth2 server instance. |
||
| 26 | * |
||
| 27 | * @var OAuth2\Server |
||
| 28 | */ |
||
| 29 | private $server; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Construct a new instance of Authorize. |
||
| 33 | * |
||
| 34 | * @param Slim $slim The slim framework application instance. |
||
| 35 | * @param OAuth2\Server $server The oauth2 server imstance. |
||
| 36 | */ |
||
| 37 | public function __construct(Slim $slim, OAuth2\Server $server) |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Call this class as a function. |
||
| 45 | * |
||
| 46 | * @return void |
||
| 47 | */ |
||
| 48 | public function __invoke() |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Register this route with the given Slim application and OAuth2 server |
||
| 59 | * |
||
| 60 | * @param Slim $slim The slim framework application instance. |
||
| 61 | * @param OAuth2\Server $server The oauth2 server instance. |
||
| 62 | * |
||
| 63 | * @return void |
||
| 64 | */ |
||
| 65 | public static function register(Slim $slim, OAuth2\Server $server) |
||
| 69 | } |
||
| 70 |