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 MethodWriter extends \Flagbit\Plantuml\TokenReflection\WriterAbstract |
||
9 | { |
||
10 | /** |
||
11 | * @param \TokenReflection\IReflectionMethod $method |
||
12 | * @return string |
||
13 | */ |
||
14 | 13 | public function writeElement(IReflectionMethod $method) |
|
20 | |||
21 | /** |
||
22 | * @param IReflectionMethod[] $methods |
||
23 | * @return string |
||
24 | */ |
||
25 | 10 | public function writeElements(array $methods) |
|
38 | |||
39 | /** |
||
40 | * @param \TokenReflection\IReflectionMethod $method |
||
41 | * @return string |
||
42 | */ |
||
43 | 13 | private function writeVisibility(IReflectionMethod $method) |
|
47 | |||
48 | /** |
||
49 | * @param \TokenReflection\IReflectionMethod $method |
||
50 | * @return string |
||
51 | */ |
||
52 | 13 | private function writeParameters(IReflectionMethod $method) |
|
61 | |||
62 | /** |
||
63 | * @param IReflectionMethod $method |
||
64 | * @param IReflectionParameter $parameter |
||
65 | * @return string |
||
66 | */ |
||
67 | 5 | private function writeParameter(IReflectionMethod $method, IReflectionParameter $parameter) |
|
87 | |||
88 | /** |
||
89 | * @param \TokenReflection\IReflectionMethod $method |
||
90 | * @return string |
||
91 | */ |
||
92 | 13 | View Code Duplication | private function writeReturnType(IReflectionMethod $method) |
105 | } |
||
106 |
If you suppress an error, we recommend checking for the error condition explicitly: