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 |
||
| 28 | class RedisService { |
||
| 29 | |||
| 30 | /** |
||
| 31 | * |
||
| 32 | * @var IConfig |
||
| 33 | */ |
||
| 34 | private $config; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * |
||
| 38 | * @var OcrJobMapper |
||
| 39 | */ |
||
| 40 | private $mapper; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * |
||
| 44 | * @var ILogger |
||
| 45 | */ |
||
| 46 | private $logger; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * |
||
| 50 | * @var IL10N |
||
| 51 | */ |
||
| 52 | private $l10n; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * |
||
| 56 | * @var resource |
||
| 57 | */ |
||
| 58 | private $queue; |
||
| 59 | |||
| 60 | /** |
||
| 61 | * |
||
| 62 | * @var resource |
||
| 63 | */ |
||
| 64 | private $statusqueue; |
||
|
|
|||
| 65 | |||
| 66 | /** |
||
| 67 | * QueueService constructor. |
||
| 68 | * |
||
| 69 | * @param OcrJobMapper $mapper |
||
| 70 | * @param IConfig $config |
||
| 71 | * @param IL10N $l10n |
||
| 72 | * @param ILogger $logger |
||
| 73 | */ |
||
| 74 | public function __construct(OcrJobMapper $mapper, IConfig $config, IL10N $l10n, ILogger $logger) { |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Inits the client and sends the task to the background worker (async) |
||
| 83 | * |
||
| 84 | * @param OcrJob $job |
||
| 85 | * @param string[] $languages |
||
| 86 | * @param string $occDir |
||
| 87 | */ |
||
| 88 | public function sendJob($job, $languages, $occDir) { |
||
| 122 | |||
| 123 | // TODO: implement reading finished jobs. |
||
| 124 | |||
| 125 | /** |
||
| 126 | * Handle the possible thrown Exceptions from all methods of this class. |
||
| 127 | * |
||
| 128 | * @param Exception $e |
||
| 129 | * @throws Exception |
||
| 130 | * @throws NotFoundException |
||
| 131 | */ |
||
| 132 | View Code Duplication | private function handleException($e) { |
|
| 143 | } |
This check marks private properties in classes that are never used. Those properties can be removed.