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 |
||
10 | class OaiPmhHarvest extends Command |
||
11 | { |
||
12 | use DispatchesJobs; |
||
13 | |||
14 | /** |
||
15 | * The name and signature of the console command. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $signature = 'colligator:harvest-oaipmh |
||
20 | {name? : Name of the harvest config as defined in configs/oaipmh.php} |
||
21 | {--from= : Start date on ISO format YYYY-MM-DD} |
||
22 | {--until= : End date on ISO format YYYY-MM-DD} |
||
23 | {--resume= : Resumption token} |
||
24 | {--daily : Harvest records modified yesterday. Cannot be combined with --from / --until}'; |
||
25 | |||
26 | /** |
||
27 | * The console command description. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $description = 'Harvest records from OAI-PMH service and store as XML files.'; |
||
32 | |||
33 | /** |
||
34 | * Create a new command instance. |
||
35 | */ |
||
36 | public function __construct() |
||
40 | |||
41 | /** |
||
42 | * Output a list of the configurations. |
||
43 | */ |
||
44 | public function listConfigurations() |
||
53 | |||
54 | public function validate() |
||
92 | |||
93 | /** |
||
94 | * Execute the console command. |
||
95 | */ |
||
96 | public function handle() |
||
134 | } |
||
135 |
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.