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 |
||
25 | View Code Duplication | class InvalidateRegexCommand extends BaseInvalidateCommand |
|
26 | { |
||
27 | protected static $defaultName = 'fos:httpcache:invalidate:regex'; |
||
28 | |||
29 | /** |
||
30 | * If no cache manager is specified explicitly, fos_http_cache.cache_manager |
||
31 | * is automatically loaded. |
||
32 | * |
||
33 | * @param CacheManager|null $cacheManager The cache manager to talk to |
||
34 | */ |
||
35 | 4 | public function __construct(CacheManager $cacheManager = null, $commandName = 'fos:httpcache:invalidate:regex') |
|
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | 4 | protected function configure() |
|
70 | |||
71 | /** |
||
72 | * {@inheritdoc} |
||
73 | */ |
||
74 | 2 | protected function execute(InputInterface $input, OutputInterface $output): int |
|
82 | } |
||
83 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.