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 |
||
| 35 | class AccessToken extends WechatAccessToken |
||
| 36 | { |
||
| 37 | use VerifyTicketTrait; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * API. |
||
| 41 | */ |
||
| 42 | const API_TOKEN_GET = 'https://api.weixin.qq.com/cgi-bin/component/api_component_token'; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * {@inheritdoc}. |
||
| 46 | */ |
||
| 47 | protected $queryName = 'component_access_token'; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * {@inheritdoc}. |
||
| 51 | */ |
||
| 52 | protected $tokenJsonKey = 'component_access_token'; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * {@inheritdoc}. |
||
| 56 | */ |
||
| 57 | protected $prefix = 'easywechat.common.component_access_token.'; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * AccessToken constructor. |
||
| 61 | * |
||
| 62 | * @param string $appId |
||
| 63 | * @param string $secret |
||
| 64 | * @param Cache $cache |
||
| 65 | * @param VerifyTicket $verifyTicket |
||
| 66 | */ |
||
| 67 | public function __construct($appId, $secret, VerifyTicket $verifyTicket, Cache $cache = null) |
||
| 73 | |||
| 74 | /** |
||
| 75 | * {@inheritdoc}. |
||
| 76 | */ |
||
| 77 | View Code Duplication | public function getTokenFromServer() |
|
| 95 | } |
||
| 96 |