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 |
||
| 9 | class Timer |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var mixed |
||
| 13 | */ |
||
| 14 | private $config; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var mixed |
||
| 18 | */ |
||
| 19 | private $harvest; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var mixed |
||
| 23 | */ |
||
| 24 | private $toggl; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @param Config $config |
||
| 28 | */ |
||
| 29 | public function __construct(Config $config = null) |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @param $timerId |
||
| 38 | * @return string |
||
| 39 | */ |
||
| 40 | public function delete(array $timerData = []) |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @param $service |
||
| 60 | * @param $timerId |
||
| 61 | * @return boolean |
||
| 62 | */ |
||
| 63 | public function deleteServiceTimer($service, $timerId) |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @return mixed |
||
| 78 | */ |
||
| 79 | public function getDescription() |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @return mixed |
||
| 86 | */ |
||
| 87 | public function getPrimaryService() |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @return mixed |
||
| 94 | */ |
||
| 95 | public function getProjects() |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @param $service |
||
| 102 | * @return mixed |
||
| 103 | */ |
||
| 104 | public function getServiceDataCache($service) |
||
| 114 | |||
| 115 | /** |
||
| 116 | * @return mixed |
||
| 117 | */ |
||
| 118 | public function getTags() |
||
| 122 | |||
| 123 | /** |
||
| 124 | * @return mixed |
||
| 125 | */ |
||
| 126 | public function isRunning() |
||
| 130 | |||
| 131 | /** |
||
| 132 | * @param $service |
||
| 133 | * @param null $action |
||
| 134 | * @param null $success |
||
| 135 | */ |
||
| 136 | View Code Duplication | public function setNotificationForService($service = null, $action = null, $success = null) |
|
| 144 | |||
| 145 | /** |
||
| 146 | * @param $description |
||
| 147 | * @param $projectsData |
||
| 148 | * @param $tagData |
||
| 149 | * @return string |
||
| 150 | */ |
||
| 151 | public function start($description = '', array $projectData = [], array $tagData = [], $specificService = null) |
||
| 187 | |||
| 188 | /** |
||
| 189 | * @return string |
||
| 190 | */ |
||
| 191 | public function stop() |
||
| 210 | |||
| 211 | /** |
||
| 212 | * @return string |
||
| 213 | */ |
||
| 214 | public function undo() |
||
| 224 | |||
| 225 | /** |
||
| 226 | * @param $name |
||
| 227 | * @param $value |
||
| 228 | */ |
||
| 229 | public function updateProperty($name, $value) |
||
| 233 | |||
| 234 | /** |
||
| 235 | * @param $needle |
||
| 236 | * @return mixed |
||
| 237 | */ |
||
| 238 | private function getItems($needle) |
||
| 257 | |||
| 258 | /** |
||
| 259 | * @param $name |
||
| 260 | * @return mixed |
||
| 261 | */ |
||
| 262 | private function getProperty($name) |
||
| 266 | } |
||
| 267 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.