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 |
||
11 | View Code Duplication | class EditorStrategy extends ListStrategy implements StrategyInterface |
|
12 | { |
||
13 | /** |
||
14 | * Initialize the editor strategy. |
||
15 | * |
||
16 | * @param string[] $editors The names to the potential editors. The first |
||
17 | * command in the list that can be located will be used. |
||
18 | * @param \Nubs\Which\Locator $commandLocator The command locator. This |
||
19 | * helps locate commands using PATH. |
||
20 | * @param \Habitat\Environment\Environment $environment The environment |
||
21 | * variable wrapper. Defaults to null, which just uses the built-in |
||
22 | * getenv. |
||
23 | */ |
||
24 | public function __construct(array $editors, CommandLocator $commandLocator, Environment $environment = null) |
||
28 | } |
||
29 |