1 | <?php |
||
16 | abstract class AbstractAPI |
||
17 | { |
||
18 | /** |
||
19 | * Http instance. |
||
20 | * |
||
21 | * @var \EntWeChat\Core\Http |
||
22 | */ |
||
23 | protected $http; |
||
24 | |||
25 | /** |
||
26 | * The request token. |
||
27 | * |
||
28 | * @var \EntWeChat\Core\AccessToken |
||
29 | */ |
||
30 | protected $accessToken; |
||
31 | |||
32 | const GET = 'get'; |
||
33 | const POST = 'post'; |
||
34 | const JSON = 'json'; |
||
35 | |||
36 | /** |
||
37 | * Constructor. |
||
38 | * |
||
39 | * @param \EntWeChat\Core\AccessToken $accessToken |
||
40 | */ |
||
41 | public function __construct(AccessToken $accessToken) |
||
45 | |||
46 | /** |
||
47 | * Return the http instance. |
||
48 | * |
||
49 | * @return \EntWeChat\Core\Http |
||
50 | */ |
||
51 | public function getHttp() |
||
63 | |||
64 | /** |
||
65 | * Set the http instance. |
||
66 | * |
||
67 | * @param \EntWeChat\Core\Http $http |
||
68 | * |
||
69 | * @return $this |
||
70 | */ |
||
71 | public function setHttp(Http $http) |
||
77 | |||
78 | /** |
||
79 | * Return the current accessToken. |
||
80 | * |
||
81 | * @return \EntWeChat\Core\AccessToken |
||
82 | */ |
||
83 | public function getAccessToken() |
||
87 | |||
88 | /** |
||
89 | * Set the request token. |
||
90 | * |
||
91 | * @param \EntWeChat\Core\AccessToken $accessToken |
||
92 | * |
||
93 | * @return $this |
||
94 | */ |
||
95 | public function setAccessToken(AccessToken $accessToken) |
||
101 | |||
102 | /** |
||
103 | * Parse JSON from response and check error. |
||
104 | * |
||
105 | * @param string $method |
||
106 | * @param array $args |
||
107 | * |
||
108 | * @return \EntWeChat\Support\Collection |
||
109 | */ |
||
110 | public function parseJSON($method, array $args) |
||
120 | |||
121 | /** |
||
122 | * Register Guzzle middlewares. |
||
123 | */ |
||
124 | protected function registerHttpMiddlewares() |
||
133 | |||
134 | /** |
||
135 | * Attache access token to request query. |
||
136 | * |
||
137 | * @return \Closure |
||
138 | */ |
||
139 | protected function accessTokenMiddleware() |
||
156 | |||
157 | /** |
||
158 | * Log the request. |
||
159 | * |
||
160 | * @return \Closure |
||
161 | */ |
||
162 | protected function logMiddleware() |
||
169 | |||
170 | /** |
||
171 | * Return retry middleware. |
||
172 | * |
||
173 | * @return \Closure |
||
174 | */ |
||
175 | protected function retryMiddleware() |
||
201 | |||
202 | /** |
||
203 | * Check the array data errors, and Throw exception when the contents contains error. |
||
204 | * |
||
205 | * @param array $contents |
||
206 | * |
||
207 | * @throws \EntWeChat\Core\Exceptions\HttpException |
||
208 | */ |
||
209 | protected function checkAndThrow(array $contents) |
||
219 | } |
||
220 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.