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 namespace nyx\auth\id\protocols\oauth2\providers; |
||
16 | class LinkedIn extends oauth2\Provider |
||
17 | { |
||
18 | /** |
||
19 | * {@inheritDoc} |
||
20 | */ |
||
21 | const SCOPE_SEPARATOR = ' '; |
||
22 | |||
23 | /** |
||
24 | * {@inheritDoc} |
||
25 | */ |
||
26 | const URL_AUTHORIZE = 'https://www.linkedin.com/oauth/v2/authorization'; |
||
27 | const URL_EXCHANGE = 'https://www.linkedin.com/oauth/v2/accessToken'; |
||
28 | const URL_IDENTIFY = 'https://api.linkedin.com/v1/people'; |
||
29 | |||
30 | /** |
||
31 | * {@inheritDoc} |
||
32 | */ |
||
33 | const IDENTITY = auth\id\identities\LinkedIn::class; |
||
34 | |||
35 | /** |
||
36 | * {@inheritDoc} |
||
37 | */ |
||
38 | protected $defaultScopes = ['r_basicprofile', 'r_emailaddress']; |
||
39 | |||
40 | /** |
||
41 | * {@inheritDoc} |
||
42 | */ |
||
43 | public function getIdentifyUrl() : string |
||
54 | |||
55 | /** |
||
56 | * {@inheritDoc} |
||
57 | */ |
||
58 | View Code Duplication | protected function getDefaultRequestOptions(auth\interfaces\Token $token = null) : array |
|
66 | } |
||
67 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.