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 |
||
| 17 | class SimpleXml extends Xml |
||
| 18 | { |
||
| 19 | |||
| 20 | /** |
||
| 21 | * SimpleXML handler |
||
| 22 | * {@inheritdoc} |
||
| 23 | */ |
||
| 24 | public function encode(array $data, $rootNode='root') |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Array to Simple XML |
||
| 40 | * |
||
| 41 | * @param \SimpleXMLElement $xml |
||
| 42 | * @param array $array |
||
| 43 | */ |
||
| 44 | View Code Duplication | protected function arrayToSimpleXml(\SimpleXMLElement $x, array $array) |
|
| 76 | |||
| 77 | /** |
||
| 78 | * Decodes any special characters entities. |
||
| 79 | * XmlWriter does this automatically. |
||
| 80 | */ |
||
| 81 | public function specialChars($var) |
||
| 85 | |||
| 86 | } |
||
| 87 |