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 |
||
7 | class Manager extends Endpoint |
||
8 | { |
||
9 | |||
10 | const RESOURCE = '/employers/{employer_id}/managers/{manager_id}/settings'; |
||
11 | |||
12 | /** |
||
13 | * @var array |
||
14 | */ |
||
15 | protected $currentUser; |
||
16 | |||
17 | /** |
||
18 | * Get manager settings |
||
19 | * @param integer $managerId |
||
20 | * @return array |
||
21 | */ |
||
22 | public function preferences($managerId = null) |
||
35 | |||
36 | /** |
||
37 | * @return null |
||
38 | * @throws HeadHunterApiException |
||
39 | */ |
||
40 | View Code Duplication | protected function getCurrentEmployerId() |
|
50 | |||
51 | protected function getCurrentUser() |
||
59 | |||
60 | View Code Duplication | protected function getCurrentManagerId() |
|
70 | } |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.