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 |
||
30 | class Authorizer extends AbstractComponent |
||
31 | { |
||
32 | /** |
||
33 | * Get auth info api. |
||
34 | */ |
||
35 | const GET_AUTH_INFO = 'https://api.weixin.qq.com/cgi-bin/component/api_query_auth'; |
||
36 | |||
37 | /** |
||
38 | * Authorization token api. |
||
39 | */ |
||
40 | const GET_AUTHORIZER_TOKEN = 'https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token'; |
||
41 | |||
42 | /** |
||
43 | * Get authorizer info api. |
||
44 | */ |
||
45 | const GET_AUTHORIZER_INFO = 'https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info'; |
||
46 | |||
47 | /** |
||
48 | * Get authorizer options api. |
||
49 | */ |
||
50 | const GET_AUTHORIZER_OPTION = 'https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_option'; |
||
51 | |||
52 | /** |
||
53 | * Set authorizer options api. |
||
54 | */ |
||
55 | const SET_AUTHORIZER_OPTION = 'https://api.weixin.qq.com/cgi-bin/component/api_set_authorizer_option'; |
||
56 | |||
57 | /** |
||
58 | * Get authorization info. |
||
59 | * |
||
60 | * @param $authCode |
||
61 | * |
||
62 | * @return \EasyWeChat\Support\Collection |
||
63 | */ |
||
64 | public function getAuthorizationInfo($authCode = null) |
||
73 | |||
74 | /** |
||
75 | * Get authorization token. |
||
76 | * |
||
77 | * @param $authorizerAppId |
||
78 | * @param $authorizerRefreshToken |
||
79 | * |
||
80 | * @return \EasyWeChat\Support\Collection |
||
81 | */ |
||
82 | View Code Duplication | public function getAuthorizationToken($authorizerAppId, $authorizerRefreshToken) |
|
92 | |||
93 | /** |
||
94 | * Get authorizer info. |
||
95 | * |
||
96 | * @param $authorizerAppId |
||
97 | * |
||
98 | * @return \EasyWeChat\Support\Collection |
||
99 | */ |
||
100 | View Code Duplication | public function getAuthorizerInfo($authorizerAppId) |
|
109 | |||
110 | /** |
||
111 | * Get options. |
||
112 | * |
||
113 | * @param $authorizerAppId |
||
114 | * @param $optionName |
||
115 | * |
||
116 | * @return \EasyWeChat\Support\Collection |
||
117 | */ |
||
118 | View Code Duplication | public function getAuthorizerOption($authorizerAppId, $optionName) |
|
128 | |||
129 | /** |
||
130 | * Set authorizer option. |
||
131 | * |
||
132 | * @param $authorizerAppId |
||
133 | * @param $optionName |
||
134 | * @param $optionValue |
||
135 | * |
||
136 | * @return \EasyWeChat\Support\Collection |
||
137 | */ |
||
138 | View Code Duplication | public function setAuthorizerOption($authorizerAppId, $optionName, $optionValue) |
|
149 | |||
150 | } |
||
151 |