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 | const RESOURCE = '/employers'; |
||
10 | |||
11 | /** |
||
12 | * Get manager settings |
||
13 | * @param integer $managerId |
||
14 | * @return array |
||
15 | */ |
||
16 | public function preferences($managerId = null) |
||
30 | |||
31 | /** |
||
32 | * @return null |
||
33 | * @throws HeadHunterApiException |
||
34 | */ |
||
35 | View Code Duplication | protected function getCurrentEmployerId() |
|
45 | |||
46 | View Code Duplication | protected function getCurrentManagerId() |
|
56 | |||
57 | /** |
||
58 | * @return array |
||
59 | */ |
||
60 | protected function getCurrentUserInfo() |
||
64 | } |
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.