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 |
||
| 15 | class Toolkit extends EasybookToolkit |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @param array|EasybookApplication $app |
||
| 19 | * |
||
| 20 | * @return null|string |
||
| 21 | */ |
||
| 22 | 34 | public static function getCurrentThemeDir(EasybookApplication $app) |
|
| 41 | |||
| 42 | /** |
||
| 43 | * Return the current resources dir. |
||
| 44 | * |
||
| 45 | * @param EasybookApplication $app |
||
| 46 | * @param null $format |
||
| 47 | * |
||
| 48 | * @return null|string |
||
| 49 | */ |
||
| 50 | 34 | public static function getCurrentResourcesDir(EasybookApplication $app, $format = null) |
|
| 59 | |||
| 60 | /** |
||
| 61 | * Return first existing resource by name. |
||
| 62 | * |
||
| 63 | * @param EasybookApplication $app |
||
| 64 | * @param $resourceName |
||
| 65 | * @param null $format |
||
| 66 | * |
||
| 67 | * @return null|string |
||
| 68 | */ |
||
| 69 | 34 | public static function getCurrentResource(EasybookApplication $app, $resourceName, $format = null) |
|
| 77 | |||
| 78 | /** |
||
| 79 | * Return the list of current resource directories, ordered by precedence. |
||
| 80 | * |
||
| 81 | * @param EasybookApplication $app |
||
| 82 | * @param null $format |
||
| 83 | * |
||
| 84 | * @return array |
||
| 85 | */ |
||
| 86 | 34 | public static function getCurrentResourceDirs(EasybookApplication $app, $format = null) |
|
| 115 | |||
| 116 | 34 | public static function getCurrentFormat(EasybookApplication $app) |
|
| 122 | |||
| 123 | public static function sprintfUTF8($format) |
||
| 134 | |||
| 135 | /** |
||
| 136 | * Extract the attributes of an HTML tag |
||
| 137 | * |
||
| 138 | * @param string $string |
||
| 139 | * |
||
| 140 | * @return array of attributes |
||
| 141 | */ |
||
| 142 | 13 | View Code Duplication | public static function parseHTMLAttributes($string) |
| 154 | |||
| 155 | /** |
||
| 156 | * Render the attributes of an HTML tag |
||
| 157 | * |
||
| 158 | * @param array $attributes |
||
| 159 | * |
||
| 160 | * @return string |
||
| 161 | */ |
||
| 162 | 13 | View Code Duplication | public static function renderHTMLAttributes(array $attributes) |
| 172 | |||
| 173 | /** |
||
| 174 | * Render the HTML tag |
||
| 175 | * |
||
| 176 | * @param string $tag |
||
| 177 | * @param string $contents |
||
| 178 | * @param array $attributes |
||
| 179 | * |
||
| 180 | * @return string |
||
| 181 | */ |
||
| 182 | 13 | public static function renderHTMLTag($tag, $contents = '', array $attributes = array()) |
|
| 193 | |||
| 194 | } |
||
| 195 |