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 CFileBasedContent |
||
| 9 | { |
||
| 10 | use \Anax\TConfigure, |
||
| 11 | \Anax\DI\TInjectionAware; |
||
| 12 | |||
| 13 | |||
| 14 | |||
| 15 | /** |
||
| 16 | * Properties. |
||
| 17 | */ |
||
| 18 | private $index = null; |
||
| 19 | private $ignoreCache = false; |
||
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | /** |
||
| 24 | * Should the cache be used or ignored. |
||
| 25 | * |
||
| 26 | * @param boolean $use true to use the cache or false to ignore the cache. |
||
| 27 | * |
||
| 28 | * @return this. |
||
|
|
|||
| 29 | */ |
||
| 30 | public function useCache($use) |
||
| 36 | |||
| 37 | |||
| 38 | |||
| 39 | /** |
||
| 40 | * Get the index as an array. |
||
| 41 | * |
||
| 42 | * @return array as index. |
||
| 43 | */ |
||
| 44 | public function getIndex() |
||
| 48 | |||
| 49 | |||
| 50 | |||
| 51 | /** |
||
| 52 | * Create the index of all content into an array. |
||
| 53 | * |
||
| 54 | * @return array as index. |
||
| 55 | */ |
||
| 56 | View Code Duplication | private function loadIndex() |
|
| 72 | |||
| 73 | |||
| 74 | |||
| 75 | /** |
||
| 76 | * Generate an index from the directory structure. |
||
| 77 | * |
||
| 78 | * @return array as table of content. |
||
| 79 | */ |
||
| 80 | private function createIndex() |
||
| 106 | |||
| 107 | |||
| 108 | |||
| 109 | /** |
||
| 110 | * Map the route to the correct entry in the index. |
||
| 111 | * |
||
| 112 | * @param string $route current route used to access page. |
||
| 113 | * |
||
| 114 | * @return string as the title for the content. |
||
| 115 | */ |
||
| 116 | private function mapRoute2Index($route) |
||
| 128 | |||
| 129 | |||
| 130 | |||
| 131 | /** |
||
| 132 | * Map url to content if such mapping can be done. |
||
| 133 | * |
||
| 134 | * @throws NotFoundException when mapping can not be done. |
||
| 135 | */ |
||
| 136 | public function contentForRoute() |
||
| 169 | } |
||
| 170 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.