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 | View Code Duplication | class TemplateHintsBlocksCommand extends AbstractMagentoStoreConfigCommand |
|
|
|||
8 | { |
||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | protected $commandName = 'dev:template-hints-blocks'; |
||
13 | |||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $commandDescription = 'Toggles template hints block names'; |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $configPath = 'dev/debug/template_hints_blocks'; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $toggleComment = 'Template Hints Blocks'; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $scope = self::SCOPE_STORE_VIEW; |
||
33 | |||
34 | /** |
||
35 | * Add admin store to interactive prompt |
||
36 | * |
||
37 | * @var bool |
||
38 | */ |
||
39 | protected $withAdminStore = true; |
||
40 | |||
41 | /** |
||
42 | * If required, handle the output and possible change of the developer IP restrictions |
||
43 | * |
||
44 | * @param \Mage_Core_Model_Store $store |
||
45 | * @param bool $disabled |
||
46 | */ |
||
47 | protected function _afterSave(\Mage_Core_Model_Store $store, $disabled) |
||
51 | } |
||
52 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.