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 |
||
8 | class JwtServiceTest extends PHPUnit_Framework_TestCase |
||
|
|||
9 | { |
||
10 | |||
11 | /** |
||
12 | * @var Mockery\MockInterface |
||
13 | */ |
||
14 | private $tokenManager; |
||
15 | |||
16 | /** |
||
17 | * @var JwtService |
||
18 | */ |
||
19 | private $jwtService; |
||
20 | |||
21 | /** |
||
22 | * setUp method |
||
23 | */ |
||
24 | public function setUp() |
||
41 | |||
42 | /** |
||
43 | * tearDown method |
||
44 | */ |
||
45 | public function tearDown() |
||
51 | |||
52 | /** |
||
53 | * testGetTokenForUser method |
||
54 | */ |
||
55 | public function testGetTokenForUser() |
||
69 | |||
70 | /** |
||
71 | * testGetUserIdFromToken method |
||
72 | */ |
||
73 | View Code Duplication | public function testGetUserIdFromToken() |
|
89 | |||
90 | /** |
||
91 | * testGetUserIdFromTokenWithInvalidClaim method |
||
92 | */ |
||
93 | View Code Duplication | public function testGetUserIdFromTokenWithInvalidClaim() |
|
109 | |||
110 | /** |
||
111 | * getToken method |
||
112 | * |
||
113 | * @param int $ttl |
||
114 | * @return string |
||
115 | */ |
||
116 | protected function getToken($ttl = 100) |
||
154 | |||
155 | } |
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.