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 |
||
| 22 | class Client extends BaseClient |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * Query redpack. |
||
| 26 | * |
||
| 27 | * @param array $params |
||
| 28 | * |
||
| 29 | * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
||
| 30 | */ |
||
| 31 | View Code Duplication | public function info(array $params) |
|
| 40 | |||
| 41 | /** |
||
| 42 | * Send normal redpack. |
||
| 43 | * |
||
| 44 | * @param array $params |
||
| 45 | * |
||
| 46 | * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
||
| 47 | */ |
||
| 48 | public function sendNormal(array $params) |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Send group redpack. |
||
| 61 | * |
||
| 62 | * @param array $params |
||
| 63 | * |
||
| 64 | * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
||
| 65 | */ |
||
| 66 | public function sendGroup(array $params) |
||
| 74 | } |
||
| 75 |