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 |
||
| 26 | class RedisUtil { |
||
| 27 | |||
| 28 | /** |
||
| 29 | * |
||
| 30 | * @var IL10N |
||
| 31 | */ |
||
| 32 | private $l10n; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * |
||
| 36 | * @var ILogger |
||
| 37 | */ |
||
| 38 | private $logger; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * |
||
| 42 | * @var IConfig |
||
| 43 | */ |
||
| 44 | private $config; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * |
||
| 48 | * @var string |
||
| 49 | */ |
||
| 50 | private $appName = 'ocr'; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * |
||
| 54 | * @param IL10N $l10n |
||
| 55 | * @param ILogger $logger |
||
| 56 | * @param IConfig $config |
||
| 57 | */ |
||
| 58 | 7 | public function __construct(IL10N $l10n, ILogger $logger, IConfig $config) { |
|
| 59 | 7 | $this->l10n = $l10n; |
|
| 60 | 7 | $this->logger = $logger; |
|
| 61 | 7 | $this->config = $config; |
|
| 62 | 7 | } |
|
| 63 | |||
| 64 | /** |
||
| 65 | * Setup the Redis instance and return to whom ever it needs. |
||
| 66 | * @codeCoverageIgnore |
||
| 67 | * |
||
| 68 | * @throws NotFoundException |
||
| 69 | * @return \Redis |
||
| 70 | */ |
||
| 71 | public function setupRedisInstance() { |
||
| 94 | } |