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 |
||
5 | class OAuth2ServiceTest extends \Codeception\TestCase\Test |
||
|
|||
6 | { |
||
7 | use Codeception\Specify; |
||
8 | |||
9 | /** |
||
10 | * @var \UnitTester |
||
11 | */ |
||
12 | protected $tester; |
||
13 | |||
14 | /** |
||
15 | * @var array |
||
16 | */ |
||
17 | protected static $token = [ |
||
18 | 'access_token' => 'mF_9.B5f-4.1JqM', |
||
19 | 'token_type' => 'Bearer', |
||
20 | 'expires_in' => 3600, |
||
21 | 'refresh_token' => 'tGzv3JOkF0XG5Qx2TlKWIA' |
||
22 | ]; |
||
23 | |||
24 | /** |
||
25 | * @inheritdoc |
||
26 | */ |
||
27 | protected function setup() |
||
31 | |||
32 | /** |
||
33 | * |
||
34 | */ |
||
35 | public function testAssertIssueAccessToken() |
||
47 | |||
48 | /** |
||
49 | * |
||
50 | */ |
||
51 | View Code Duplication | public function testAssertValidateAccessToken() |
|
58 | |||
59 | /** |
||
60 | * |
||
61 | */ |
||
62 | View Code Duplication | public function testAssertGetResourceOwnerId() |
|
70 | |||
71 | /** |
||
72 | * |
||
73 | */ |
||
74 | View Code Duplication | public function testAssertGetResourceOwnerType() |
|
82 | |||
83 | /** |
||
84 | * |
||
85 | */ |
||
86 | View Code Duplication | public function testAssertGetClientId() |
|
94 | |||
95 | /** |
||
96 | * @return League\OAuth2\Server\AuthorizationServer |
||
97 | */ |
||
98 | private function createAuthorizationServer() |
||
106 | |||
107 | /** |
||
108 | * @return League\OAuth2\Server\ResourceServer |
||
109 | */ |
||
110 | private function createResourceServer() |
||
119 | } |
||
120 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.