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 |
||
8 | class PHPRedisAdapter implements RedisAdapterInterface |
||
9 | { |
||
10 | |||
11 | private $redis; |
||
12 | |||
13 | public function __construct(\Redis $redis) |
||
17 | |||
18 | public function ping() |
||
26 | |||
27 | public function bRPopLPush(string $source, string $destination, int $timeout = null) |
||
35 | |||
36 | public function hGet(string $key, string $field) |
||
44 | |||
45 | public function sAdd(string $key, array $members) |
||
53 | |||
54 | public function sIsMember(string $key, string $value): bool |
||
62 | |||
63 | public function sMembers(string $key): array |
||
71 | |||
72 | public function lLen(string $key): int |
||
80 | |||
81 | public function lRange(string $key, int $offset = 0, int $limit = 10): array |
||
89 | |||
90 | View Code Duplication | public function zScore(string $key, string $value) |
|
99 | |||
100 | public function del(string $key) |
||
108 | |||
109 | public function evalScript(string $path, array $args) |
||
118 | } |
||
119 |