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 |
||
27 | class RedisService { |
||
28 | |||
29 | /** |
||
30 | * |
||
31 | * @var IConfig |
||
32 | */ |
||
33 | private $config; |
||
34 | |||
35 | /** |
||
36 | * |
||
37 | * @var OcrJobMapper |
||
38 | */ |
||
39 | private $mapper; |
||
40 | |||
41 | /** |
||
42 | * |
||
43 | * @var ILogger |
||
44 | */ |
||
45 | private $logger; |
||
46 | |||
47 | /** |
||
48 | * |
||
49 | * @var IL10N |
||
50 | */ |
||
51 | private $l10n; |
||
52 | |||
53 | /** |
||
54 | * QueueService constructor. |
||
55 | * |
||
56 | * @param OcrJobMapper $mapper |
||
57 | * @param IConfig $config |
||
58 | * @param IL10N $l10n |
||
59 | * @param ILogger $logger |
||
60 | */ |
||
61 | public function __construct(OcrJobMapper $mapper, IConfig $config, IL10N $l10n, ILogger $logger) { |
||
67 | |||
68 | /** |
||
69 | * Inits the client and sends the task to the background worker (async) |
||
70 | * |
||
71 | * @param OcrJob $job |
||
72 | * @param string[] $languages |
||
73 | * @param string $occDir |
||
74 | */ |
||
75 | public function sendJob($job, $languages, $occDir) { |
||
98 | |||
99 | // TODO: implement reading finished jobs. |
||
100 | |||
101 | /** |
||
102 | * Setup the Redis instance and return to whom ever it needs. |
||
103 | * |
||
104 | * @throws NotFoundException |
||
105 | * @return \Redis |
||
106 | */ |
||
107 | private function setupRedisInstance() { |
||
133 | |||
134 | /** |
||
135 | * Handle the possible thrown Exceptions from all methods of this class. |
||
136 | * |
||
137 | * @param Exception $e |
||
138 | * @throws Exception |
||
139 | * @throws NotFoundException |
||
140 | */ |
||
141 | View Code Duplication | private function handleException($e) { |
|
152 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.