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 |
||
13 | class Pool extends \PHPDaemon\Network\Client { |
||
14 | public $servConnSub = []; |
||
15 | |||
16 | protected $currentMasterAddr; |
||
17 | |||
18 | /** |
||
19 | * @TODO |
||
|
|||
20 | * @param string $key |
||
21 | * @param integer $timeout |
||
22 | * @return Lock |
||
23 | */ |
||
24 | public function lock($key, $timeout) { |
||
27 | |||
28 | /** |
||
29 | * Easy wrapper for queue of eval's |
||
30 | * @param callable $cb |
||
31 | * @return MultiEval |
||
32 | */ |
||
33 | public function meval($cb = null) { |
||
36 | |||
37 | /** |
||
38 | * Wrapper for scans commands |
||
39 | * @param string $cmd Command |
||
40 | * @param array $args Arguments |
||
41 | * @param cllable $cbEnd Callback |
||
42 | * @param integer $limit Limit |
||
43 | * @return AutoScan |
||
44 | */ |
||
45 | public function autoscan($cmd, $args = [], $cbEnd = null, $limit = null) { |
||
48 | |||
49 | /** |
||
50 | * Setting default config options |
||
51 | * Overriden from NetworkClient::getConfigDefaults |
||
52 | * @return array|bool |
||
53 | */ |
||
54 | protected function getConfigDefaults() { |
||
78 | |||
79 | /** |
||
80 | * @TODO |
||
81 | * @param string $chan |
||
82 | * @return integer |
||
83 | */ |
||
84 | public function getLocalSubscribersCount($chan) { |
||
90 | |||
91 | /** |
||
92 | * Magic __call |
||
93 | * Example: |
||
94 | * $redis->lpush('mylist', microtime(true)); |
||
95 | * @param string $name Command name |
||
96 | * @param array $args Arguments |
||
97 | * @return void |
||
98 | */ |
||
99 | public function __call($cmd, $args) { |
||
132 | |||
133 | /** |
||
134 | * @TODO |
||
135 | * @param string $addr |
||
136 | * @param string $cmd |
||
137 | * @param array $args |
||
138 | * @param callable $cb |
||
139 | * @callback $cb ( ) |
||
140 | * @return void |
||
141 | */ |
||
142 | protected function sendCommand($addr, $cmd, $args, $cb) { |
||
156 | |||
157 | /** |
||
158 | * @TODO |
||
159 | * @param string $cmd |
||
160 | * @param array $args |
||
161 | * @param callable $cb |
||
162 | * @callback $cb ( ) |
||
163 | * @return boolean |
||
164 | */ |
||
165 | protected function sendSubCommand($cmd, $args, $cb) { |
||
175 | } |
||
176 |
This check looks
TODO
comments that have been left in the code.``TODO``s show that something is left unfinished and should be attended to.