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 | ||
| 22 | class GearmanWorkerService { | ||
| 23 | |||
| 24 | /** | ||
| 25 | * @var ILogger | ||
| 26 | */ | ||
| 27 | private $logger; | ||
| 28 | |||
| 29 | /** | ||
| 30 | * GearmanWorkerService constructor. | ||
| 31 | * | ||
| 32 | * @param ILogger $logger | ||
| 33 | */ | ||
| 34 | 2 | 	public function __construct(ILogger $logger) { | |
| 37 | |||
| 38 | /** | ||
| 39 | * Checks if a worker is active and registered at the Gearman Job Server. | ||
| 40 | * returns false if not. | ||
| 41 | * @return boolean|null | ||
| 42 | */ | ||
| 43 | 	public function workerExists() { | ||
| 63 | |||
| 64 | /** | ||
| 65 | * Handle the possible thrown Exceptions from all methods of this class. | ||
| 66 | * | ||
| 67 | * @param Exception $e | ||
| 68 | * @throws Exception | ||
| 69 | * @throws NotFoundException | ||
| 70 | */ | ||
| 71 | View Code Duplication | 	private function handleException($e) { | |
| 79 | |||
| 80 | } |