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 |
||
8 | class CacheBlockDecorator extends BaseCacheDecorator implements BlockRepository |
||
9 | { |
||
10 | public function __construct(BlockRepository $block) |
||
16 | |||
17 | /** |
||
18 | * Get all online blocks in the given language |
||
19 | * @param string $lang |
||
20 | * @return object |
||
21 | */ |
||
22 | View Code Duplication | public function allOnlineInLang($lang) |
|
34 | |||
35 | /** |
||
36 | * Get a block body by its name if it's online |
||
37 | * @param string $name |
||
38 | * @return string |
||
39 | */ |
||
40 | View Code Duplication | public function get($name) |
|
52 | } |
||
53 |