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 |
||
23 | class GearmanWorkerService { |
||
24 | |||
25 | /** |
||
26 | * @var ILogger |
||
27 | */ |
||
28 | private $logger; |
||
29 | |||
30 | /** |
||
31 | * @var IL10N |
||
32 | */ |
||
33 | private $l10n; |
||
34 | |||
35 | /** |
||
36 | * GearmanWorkerService constructor. |
||
37 | * |
||
38 | * @param IL10N $l10n |
||
39 | * @param ILogger $logger |
||
40 | */ |
||
41 | 2 | public function __construct(IL10N $l10n, ILogger $logger) { |
|
45 | |||
46 | /** |
||
47 | * Checks if a worker is active and registered at the Gearman Job Server. |
||
48 | * returns false if not. |
||
49 | * @return boolean|null |
||
50 | */ |
||
51 | public function workerExists() { |
||
71 | |||
72 | /** |
||
73 | * Handle the possible thrown Exceptions from all methods of this class. |
||
74 | * |
||
75 | * @param Exception $e |
||
76 | * @throws Exception |
||
77 | * @throws NotFoundException |
||
78 | */ |
||
79 | View Code Duplication | private function handleException($e) { |
|
87 | |||
88 | } |