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 isRunning()  | 
            ||
| 99 | |||
| 100 | /**  | 
            ||
| 101 | * @param $service  | 
            ||
| 102 | * @param null $action  | 
            ||
| 103 | * @param null $success  | 
            ||
| 104 | */  | 
            ||
| 105 | View Code Duplication | public function setNotificationForService($service = null, $action = null, $success = null)  | 
            |
| 113 | |||
| 114 | /**  | 
            ||
| 115 | * @param $description  | 
            ||
| 116 | * @param $projectsData  | 
            ||
| 117 | * @param $tagData  | 
            ||
| 118 | * @return string  | 
            ||
| 119 | */  | 
            ||
| 120 | public function start($description = '', array $projectData = [], array $tagData = [], $specificService = null)  | 
            ||
| 156 | |||
| 157 | /**  | 
            ||
| 158 | * @return string  | 
            ||
| 159 | */  | 
            ||
| 160 | public function stop()  | 
            ||
| 179 | |||
| 180 | /**  | 
            ||
| 181 | * @return string  | 
            ||
| 182 | */  | 
            ||
| 183 | public function undo()  | 
            ||
| 193 | |||
| 194 | /**  | 
            ||
| 195 | * @param $name  | 
            ||
| 196 | * @param $value  | 
            ||
| 197 | */  | 
            ||
| 198 | public function updateProperty($name, $value)  | 
            ||
| 202 | |||
| 203 | /**  | 
            ||
| 204 | * @param $name  | 
            ||
| 205 | * @return mixed  | 
            ||
| 206 | */  | 
            ||
| 207 | private function getProperty($name)  | 
            ||
| 211 | }  | 
            ||
| 212 | 
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.