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 |
||
22 | class MarkdownTansformer extends Transformer implements TransformerInterface |
||
23 | { |
||
24 | |||
25 | use TransformerInitTrait; |
||
26 | |||
27 | /** |
||
28 | * Transforms the message string. |
||
29 | * @param string $string |
||
30 | * @return void |
||
31 | */ |
||
32 | 2 | View Code Duplication | private function transform($string) |
45 | |||
46 | /** |
||
47 | * Builds the Mardown link replacement for the Markdown transformation. |
||
48 | * @param string $link The URL |
||
49 | * @param string $text The name of the link |
||
50 | * @param array $tag |
||
51 | * @return string |
||
52 | */ |
||
53 | 2 | private function buildMarkdownLink($link, $text, $tag) |
|
58 | } |
||
59 |