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 | abstract class AbstractCronCommand extends AbstractMagentoCommand | ||
| 11 | { | ||
| 12 | /** | ||
| 13 | * @var \Magento\Framework\App\State | ||
| 14 | */ | ||
| 15 | protected $state; | ||
| 16 | |||
| 17 | /** | ||
| 18 | * @var \Magento\Cron\Model\ConfigInterface | ||
| 19 | */ | ||
| 20 | protected $cronConfig; | ||
| 21 | |||
| 22 | /** | ||
| 23 | * @var \Magento\Framework\App\Config\ScopeConfigInterface | ||
| 24 | */ | ||
| 25 | protected $scopeConfig; | ||
| 26 | |||
| 27 | /** | ||
| 28 | * @var \Magento\Cron\Model\ResourceModel\Schedule\Collection | ||
| 29 | */ | ||
| 30 | protected $cronScheduleCollection; | ||
| 31 | |||
| 32 | /** | ||
| 33 | * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface | ||
| 34 | */ | ||
| 35 | protected $timezone; | ||
| 36 | |||
| 37 | /** | ||
| 38 | * @param \Magento\Framework\App\State $state | ||
| 39 | * @param \Magento\Framework\Event\ManagerInterface $eventManager | ||
| 40 | * @param \Magento\Cron\Model\ConfigInterface $cronConfig | ||
| 41 | * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone | ||
| 42 | * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig | ||
| 43 | * @param \Magento\Cron\Model\ResourceModel\Schedule\Collection $cronScheduleCollection | ||
| 44 | */ | ||
| 45 | public function inject( | ||
| 59 | |||
| 60 | /** | ||
| 61 | * @return array | ||
| 62 | */ | ||
| 63 | protected function getJobs() | ||
| 88 | |||
| 89 | /** | ||
| 90 | * @param string $jobCode | ||
| 91 | * @return array | ||
| 92 | */ | ||
| 93 | protected function getJobConfig($jobCode) | ||
| 105 | |||
| 106 | /** | ||
| 107 | * @param array $job | ||
| 108 | * @return array | ||
| 109 | */ | ||
| 110 | protected function getSchedule(array $job) | ||
| 133 | |||
| 134 | /** | ||
| 135 | * @param InputInterface $input | ||
| 136 | * @param OutputInterface $output | ||
| 137 | * @param array $jobs | ||
| 138 | * @return string | ||
| 139 | * @throws \InvalidArgumentException | ||
| 140 | * @throws \Exception | ||
| 141 | */ | ||
| 142 | protected function askJobCode(InputInterface $input, OutputInterface $output, $jobs) | ||
| 164 | |||
| 165 | /** | ||
| 166 | * @param InputInterface $input | ||
| 167 | * @param OutputInterface $output | ||
| 168 | * @return array | ||
| 169 | */ | ||
| 170 | protected function getJobForExecuteMethod(InputInterface $input, OutputInterface $output) | ||
| 200 | } | ||
| 201 | 
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.