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 |
||
| 32 | class AccessToken extends WechatAccessToken |
||
| 33 | { |
||
| 34 | /** |
||
| 35 | * API. |
||
| 36 | */ |
||
| 37 | const API_TOKEN_GET = 'https://api.weixin.qq.com/cgi-bin/component/api_component_token'; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * {@inheritdoc}. |
||
| 41 | */ |
||
| 42 | protected $queryName = 'component_access_token'; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * {@inheritdoc}. |
||
| 46 | */ |
||
| 47 | protected $tokenJsonKey = 'component_access_token'; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * {@inheritdoc}. |
||
| 51 | */ |
||
| 52 | protected $prefix = 'easywechat.common.component_access_token.'; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * {@inheritdoc}. |
||
| 56 | */ |
||
| 57 | View Code Duplication | public function getTokenFromServer() |
|
| 75 | |||
| 76 | /** |
||
| 77 | * Get component verify ticket. |
||
| 78 | * |
||
| 79 | * @return string |
||
| 80 | */ |
||
| 81 | private function getComponentVerifyTicket() |
||
| 85 | } |
||
| 86 |