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 |
||
29 | class PluginDynamic extends BlockPlugin implements ICompilableBlock |
||
30 | { |
||
31 | /** |
||
32 | * |
||
33 | */ |
||
34 | public function init() |
||
37 | |||
38 | /** |
||
39 | * @param Compiler $compiler |
||
40 | * @param array $params |
||
41 | * @param string $prepend |
||
42 | * @param string $append |
||
43 | * @param string $type |
||
44 | * |
||
45 | * @return string |
||
46 | */ |
||
47 | public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) |
||
51 | |||
52 | /** |
||
53 | * @param Compiler $compiler |
||
54 | * @param array $params |
||
55 | * @param string $prepend |
||
56 | * @param string $append |
||
57 | * @param string $content |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) |
||
85 | |||
86 | /** |
||
87 | * @param $output |
||
88 | * @param $dynamicId |
||
89 | * @param $compiledFile |
||
90 | * |
||
91 | * @return mixed|string |
||
92 | */ |
||
93 | public static function unescape($output, $dynamicId, $compiledFile) |
||
106 | |||
107 | /** |
||
108 | * @param $match |
||
109 | * |
||
110 | * @return mixed |
||
111 | */ |
||
112 | public static function unescapePhp($match) |
||
116 | } |
||
117 |