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 |
||
24 | View Code Duplication | class RefreshPathCommand extends BaseInvalidateCommand |
|
25 | { |
||
26 | use PathSanityCheck; |
||
27 | |||
28 | protected static $defaultName = 'fos:httpcache:refresh:path'; |
||
29 | |||
30 | /** |
||
31 | * If no cache manager is specified explicitly, fos_http_cache.cache_manager |
||
32 | * is automatically loaded. |
||
33 | * |
||
34 | * @param CacheManager|null $cacheManager The cache manager to talk to |
||
35 | */ |
||
36 | 4 | public function __construct(CacheManager $cacheManager = null) |
|
37 | { |
||
38 | 4 | if (2 <= func_num_args()) { |
|
39 | @trigger_error('Passing a command name in the constructor is deprecated and will be removed in version 3', E_USER_DEPRECATED); |
||
|
|||
40 | static::$defaultName = func_get_arg(1); |
||
41 | } |
||
42 | 4 | parent::__construct($cacheManager); |
|
43 | 4 | } |
|
44 | |||
45 | /** |
||
46 | * {@inheritdoc} |
||
47 | */ |
||
48 | 4 | protected function configure() |
|
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | 2 | protected function execute(InputInterface $input, OutputInterface $output) |
|
84 | } |
||
85 |
If you suppress an error, we recommend checking for the error condition explicitly: