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 CoreAccessToken |
||
33 | { |
||
34 | /** |
||
35 | * VerifyTicket. |
||
36 | * |
||
37 | * @var \EasyWeChat\OpenPlatform\VerifyTicket |
||
38 | */ |
||
39 | protected $verifyTicket; |
||
40 | |||
41 | /** |
||
42 | * API. |
||
43 | */ |
||
44 | const API_TOKEN_GET = 'https://api.weixin.qq.com/cgi-bin/component/api_component_token'; |
||
45 | |||
46 | /** |
||
47 | * {@inheritdoc}. |
||
48 | */ |
||
49 | protected $queryName = 'component_access_token'; |
||
50 | |||
51 | /** |
||
52 | * {@inheritdoc}. |
||
53 | */ |
||
54 | protected $tokenJsonKey = 'component_access_token'; |
||
55 | |||
56 | /** |
||
57 | * {@inheritdoc}. |
||
58 | */ |
||
59 | protected $prefix = 'easywechat.open_platform.component_access_token.'; |
||
60 | |||
61 | /** |
||
62 | * Set VerifyTicket. |
||
63 | * |
||
64 | * @param EasyWeChat\OpenPlatform\VerifyTicket $verifyTicket |
||
65 | * |
||
66 | * @return $this |
||
67 | */ |
||
68 | 12 | public function setVerifyTicket(VerifyTicket $verifyTicket) |
|
74 | |||
75 | /** |
||
76 | * {@inheritdoc}. |
||
77 | */ |
||
78 | View Code Duplication | public function getTokenFromServer() |
|
96 | } |
||
97 |