1 | <?php |
||
28 | class Soundcloud |
||
29 | { |
||
30 | const VERSION = '2.2.3'; |
||
31 | 22 | const LIB_NAME = 'Njasm-Soundcloud'; |
|
32 | const LIB_URL = 'https://www.github.com/njasm/soundcloud'; |
||
33 | 22 | ||
34 | 22 | protected $resource; |
|
35 | 22 | protected $request; |
|
36 | protected $response; |
||
37 | protected $auth; |
||
38 | protected $factory; |
||
39 | protected $responseFormat; |
||
40 | |||
41 | /** @var Container */ |
||
42 | 2 | protected $container; |
|
43 | |||
44 | 2 | public function __construct($clientID = null, $clientSecret = null, $authCallbackUri = null) |
|
51 | |||
52 | 3 | protected function initialize() |
|
68 | |||
69 | /** |
||
70 | * Get ClientID for this instance |
||
71 | * |
||
72 | 1 | * @return string The ClientID set for this instance |
|
73 | */ |
||
74 | 1 | public function getAuthClientID() |
|
78 | |||
79 | /** |
||
80 | * Get the access token. |
||
81 | * |
||
82 | * @return mixed the token, else null is returned |
||
83 | */ |
||
84 | public function getAuthToken() |
||
88 | |||
89 | /** |
||
90 | * Get the token scope. |
||
91 | * |
||
92 | * @return mixed the scope for this access token, null if empty |
||
93 | */ |
||
94 | public function getAuthScope() |
||
98 | |||
99 | /** |
||
100 | * Get the token scope. |
||
101 | * |
||
102 | * @return mixed the scope for this access token, null if empty |
||
103 | */ |
||
104 | public function getExpires() |
||
108 | |||
109 | /** |
||
110 | * Set the Auth access token. |
||
111 | * |
||
112 | * @return void |
||
113 | */ |
||
114 | public function setAccessToken($accessToken) |
||
118 | |||
119 | /** |
||
120 | * Set the Auth Scope. |
||
121 | * |
||
122 | * @return void |
||
123 | */ |
||
124 | public function setAuthScope($scope) |
||
128 | 3 | ||
129 | 3 | /** |
|
130 | * Set the Auth Expires. |
||
131 | * |
||
132 | * @return void |
||
133 | */ |
||
134 | public function setAuthExpires($expires) |
||
138 | |||
139 | 1 | /** |
|
140 | * Set the Auth refresh token. |
||
141 | 1 | * |
|
142 | 1 | * @return void |
|
143 | 1 | */ |
|
144 | public function setRefreshToken($refreshToken) |
||
148 | |||
149 | |||
150 | /** |
||
151 | * Sets up a GET Resource. |
||
152 | * |
||
153 | 5 | * @param string $path |
|
154 | * @param array $params |
||
155 | 5 | * @return \Njasm\Soundcloud\Soundcloud |
|
156 | 5 | */ |
|
157 | 5 | public function get($path, array $params = array()) |
|
163 | |||
164 | /** |
||
165 | * Sets up a PUT Resource. |
||
166 | * |
||
167 | 1 | * @param string $path |
|
168 | * @param array $params |
||
169 | 1 | * @return \Njasm\Soundcloud\Soundcloud |
|
170 | 1 | */ |
|
171 | 1 | public function put($path, array $params = array()) |
|
177 | |||
178 | /** |
||
179 | 22 | * Sets up a POST Resource. |
|
180 | * |
||
181 | 22 | * @param string $path |
|
182 | * @param array $params |
||
183 | * @return \Njasm\Soundcloud\Soundcloud |
||
184 | */ |
||
185 | public function post($path, array $params = array()) |
||
191 | 3 | ||
192 | /** |
||
193 | 3 | * Sets up a DELETE Resource. |
|
194 | 1 | * |
|
195 | * @param string $path |
||
196 | * @param array $params |
||
197 | 2 | * @return \Njasm\Soundcloud\Soundcloud |
|
198 | */ |
||
199 | 2 | public function delete($path, array $params = array()) |
|
207 | |||
208 | 6 | /** |
|
209 | * @param string $interface the interface to build |
||
210 | 6 | * @param array $params the interface object dependencies |
|
211 | 6 | * @return object |
|
212 | 6 | */ |
|
213 | 6 | protected function make($interface, array $params = array()) |
|
218 | |||
219 | /** |
||
220 | * Sets resource params. |
||
221 | * |
||
222 | * @param array $params |
||
223 | * @return \Njasm\Soundcloud\Soundcloud |
||
224 | * @throws RuntimeException |
||
225 | 1 | */ |
|
226 | public function setParams(array $params = array()) |
||
236 | |||
237 | /** |
||
238 | 1 | * Executes the request against soundcloud api. |
|
239 | * |
||
240 | 1 | * @param array $params |
|
241 | 1 | * @return \Njasm\Soundcloud\Request\ResponseInterface |
|
242 | */ |
||
243 | public function request(array $params = array()) |
||
254 | 5 | ||
255 | 5 | /** |
|
256 | * Get Last Curl Response object. |
||
257 | * |
||
258 | * @return mixed The Response Object, null if no request was yet made |
||
259 | */ |
||
260 | public function getCurlResponse() |
||
264 | 7 | ||
265 | /** |
||
266 | 7 | * Sets the Accept Header to application/xml. |
|
267 | * |
||
268 | * @deprecated Soundcloud does not support XML responses anymore. |
||
269 | 7 | * @see https://github.com/njasm/soundcloud/issues/16 |
|
270 | * |
||
271 | 7 | * @return Soundcloud |
|
272 | */ |
||
273 | public function asXml() |
||
278 | |||
279 | /** |
||
280 | 11 | * Sets the Accept Header to application/json. |
|
281 | * |
||
282 | 11 | * @deprecated Soundcloud does not support XML responses anymore and calling this method will be redundant. |
|
283 | * @see https://github.com/njasm/soundcloud/issues/16 |
||
284 | * |
||
285 | * @return Soundcloud |
||
286 | */ |
||
287 | public function asJson() |
||
292 | |||
293 | /** |
||
294 | * Set response format for Request. |
||
295 | * |
||
296 | * @param \Njasm\Soundcloud\Request\RequestInterface |
||
297 | * @return void |
||
298 | */ |
||
299 | protected function setResponseFormat(RequestInterface $request) |
||
307 | |||
308 | /** |
||
309 | * Build array of auth params for the next request. |
||
310 | * |
||
311 | * @param array $params |
||
312 | * @param bool $includeClientSecret |
||
313 | * @return array |
||
314 | */ |
||
315 | protected function mergeAuthParams(array $params = array(), $includeClientSecret = false) |
||
319 | } |
||
320 |
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.