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 RedisCachePersistentTest extends AbstractTestCases |
||
| 7 | { |
||
| 8 | protected function setUp() |
||
| 9 | { |
||
| 10 | $handler = new Redis(); |
||
| 11 | $handler->pconnect( |
||
| 12 | $this->redisConfig['host'], |
||
| 13 | $this->redisConfig['port'], |
||
| 14 | $this->redisConfig['timeout'], |
||
| 15 | $this->redisConfig['persistentId'] |
||
| 16 | ); |
||
| 17 | $handler->select($this->redisConfig['dbIndex']); |
||
| 18 | $this->client = new c\RedisCache($handler); |
||
| 19 | $this->client->clear(); |
||
| 24 |