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 |
||
| 6 | class RedisCacheTest extends AbstractTestCases |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * @var \Soupmix\Cache\RedisCache $client |
||
| 10 | */ |
||
| 11 | protected $client = null; |
||
| 12 | |||
| 13 | protected function setUp() |
||
| 14 | { |
||
| 15 | $handler = new Redis(); |
||
| 16 | $handler->connect( |
||
| 17 | $this->redisConfig['host'], |
||
| 18 | $this->redisConfig['port'], |
||
| 19 | $this->redisConfig['timeout'], |
||
| 20 | null, |
||
| 21 | $this->redisConfig['reconnectAttempt'] |
||
| 28 |