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\oauth1\signers; |
||
21 | View Code Duplication | class RsaSha1 extends oauth1\Signer |
|
|
|||
22 | { |
||
23 | /** |
||
24 | * {@inheritDoc} |
||
25 | */ |
||
26 | public function getMethod() : string |
||
30 | |||
31 | /** |
||
32 | * {@inheritDoc} |
||
33 | * |
||
34 | * Note: The OAUth Token is entirely ignored in this signing flow, as per spec. |
||
35 | */ |
||
36 | public function sign(Request $request, array $params, auth\id\credentials\Client $client, auth\interfaces\Credentials $token = null) : string |
||
42 | |||
43 | /** |
||
44 | * Returns the base signature generator used by this Request Signer. |
||
45 | * |
||
46 | * @return auth\interfaces\Signer |
||
47 | */ |
||
48 | protected function getGenerator() : auth\interfaces\Signer |
||
54 | } |
||
55 |
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.