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  | 
            ||
| 19 | class AppConfigService { | 
            ||
| 20 | |||
| 21 | /**  | 
            ||
| 22 | *  | 
            ||
| 23 | * @var string  | 
            ||
| 24 | */  | 
            ||
| 25 | private $appName = 'ocr';  | 
            ||
| 26 | |||
| 27 | /**  | 
            ||
| 28 | *  | 
            ||
| 29 | * @var IConfig  | 
            ||
| 30 | */  | 
            ||
| 31 | private $config;  | 
            ||
| 32 | |||
| 33 | /**  | 
            ||
| 34 | *  | 
            ||
| 35 | * @var IL10N  | 
            ||
| 36 | */  | 
            ||
| 37 | private $l10n;  | 
            ||
| 38 | |||
| 39 | /**  | 
            ||
| 40 | * Constructor  | 
            ||
| 41 | *  | 
            ||
| 42 | * @param IConfig $config  | 
            ||
| 43 | * @param IL10N $l10n  | 
            ||
| 44 | */  | 
            ||
| 45 | 30 |     public function __construct(IConfig $config, IL10N $l10n) { | 
            |
| 49 | |||
| 50 | /**  | 
            ||
| 51 | * Get a value by key  | 
            ||
| 52 | *  | 
            ||
| 53 | * @param string $key  | 
            ||
| 54 | * @return string  | 
            ||
| 55 | */  | 
            ||
| 56 | 2 |     public function getAppValue($key) { | 
            |
| 59 | |||
| 60 | /**  | 
            ||
| 61 | * Evaluate if all redis related settings are set.  | 
            ||
| 62 | *  | 
            ||
| 63 | * @return boolean  | 
            ||
| 64 | */  | 
            ||
| 65 | 4 |     public function evaluateRedisSettings() { | 
            |
| 74 | |||
| 75 | /**  | 
            ||
| 76 | * Set a value for the given key.  | 
            ||
| 77 | *  | 
            ||
| 78 | * @param string $key  | 
            ||
| 79 | * @param string $value  | 
            ||
| 80 | * @return string  | 
            ||
| 81 | * @throws NotFoundException  | 
            ||
| 82 | */  | 
            ||
| 83 | 19 |     public function setAppValue($key, $value) { | 
            |
| 103 | |||
| 104 | /**  | 
            ||
| 105 | * Checks for the right languages format.  | 
            ||
| 106 | *  | 
            ||
| 107 | * @param string $value  | 
            ||
| 108 | * @throws NotFoundException  | 
            ||
| 109 | */  | 
            ||
| 110 | 4 |     private function checkLanguages($value) { | 
            |
| 115 | |||
| 116 | /**  | 
            ||
| 117 | * Checks for the right redis host format.  | 
            ||
| 118 | *  | 
            ||
| 119 | * @param string $value  | 
            ||
| 120 | * @throws NotFoundException  | 
            ||
| 121 | */  | 
            ||
| 122 | 6 |     private function checkRedisHost($value) { | 
            |
| 129 | |||
| 130 | /**  | 
            ||
| 131 | * Checks for the right redis port format.  | 
            ||
| 132 | *  | 
            ||
| 133 | * @param string $value  | 
            ||
| 134 | * @throws NotFoundException  | 
            ||
| 135 | */  | 
            ||
| 136 | 5 |     private function checkRedisPort($value) { | 
            |
| 141 | |||
| 142 | /**  | 
            ||
| 143 | * Checks for the right redis db format.  | 
            ||
| 144 | *  | 
            ||
| 145 | * @param string $value  | 
            ||
| 146 | * @throws NotFoundException  | 
            ||
| 147 | */  | 
            ||
| 148 | 3 |     private function checkRedisDb($value) { | 
            |
| 153 | }  |