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 |
||
16 | View Code Duplication | class Auth |
|
17 | { |
||
18 | /** @var TwitchRequest */ |
||
19 | protected $request; |
||
20 | |||
21 | const URI_AUTH = 'oauth2/authorize'; |
||
22 | const URI_AUTH_TOKEN = 'oauth2/token'; |
||
23 | |||
24 | public function __construct(TwitchRequest $request) |
||
28 | |||
29 | /** |
||
30 | * Get login URL for authentication |
||
31 | * @param string $queryString |
||
32 | * @return string |
||
33 | * @throws TwitchSDKException |
||
34 | */ |
||
35 | public function getLoginURL($queryString) |
||
39 | |||
40 | /** |
||
41 | * Get authentication access token |
||
42 | * @param string $queryString |
||
43 | * @return \stdClass |
||
44 | * @throws TwitchSDKException |
||
45 | */ |
||
46 | public function getAccessToken($queryString) |
||
50 | } |
||
51 |