Passed
Branch master (422c77)
by Haridarshan
02:34
created
src/Instagram.php 4 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -261,6 +261,10 @@  discard block
 block discarded – undo
261 261
 	*
262 262
 	* return string (Signature)
263 263
 	*/
264
+
265
+	/**
266
+	 * @param string $auth
267
+	 */
264 268
 	protected function secureRequest($endpoint, $auth, $params){	
265 269
 		if (!is_array($params)) {
266 270
 			$params = array();	
@@ -367,6 +371,10 @@  discard block
 block discarded – undo
367 371
 	* Getter: Client Id
368 372
 	* @return: string
369 373
 	*/
374
+
375
+	/**
376
+	 * @return string
377
+	 */
370 378
 	public function getClientSecret(){
371 379
 		return $this->client_secret;	
372 380
 	}
@@ -384,6 +392,10 @@  discard block
 block discarded – undo
384 392
 	* Getter: Callback Url
385 393
 	* @return: string
386 394
 	*/
395
+
396
+	/**
397
+	 * @return string
398
+	 */
387 399
 	public function getCallbackUrl(){
388 400
 		return $this->callback_url;	
389 401
 	}
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,6 @@
 block discarded – undo
5 5
 use GuzzleHttp\Client;
6 6
 use GuzzleHttp\ClientInterface;
7 7
 use GuzzleHttp\Psr7;
8
-use Psr\Http\Message\RequestInterface;
9 8
 use GuzzleHttp\Exception\ClientException;
10 9
 
11 10
 /**
Please login to merge, or discard this patch.
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
 	}
132 132
 	
133 133
 	/**
134
-	* Make URLs for user browser navigation.
135
-	*
136
-	* @param string $path
137
-	* @param array  $parameters
138
-	*
139
-	* @return string
140
-	*/
134
+	 * Make URLs for user browser navigation.
135
+	 *
136
+	 * @param string $path
137
+	 * @param array  $parameters
138
+	 *
139
+	 * @return string
140
+	 */
141 141
 	public function getUrl($path, array $parameters){		
142 142
 		if (is_array($parameters)) {			
143 143
 			if (isset($parameters['scope']) and count(array_diff($parameters['scope'], $this->default_scopes)) === 0) {
@@ -438,19 +438,19 @@  discard block
 block discarded – undo
438 438
 	*
439 439
 	* @return void
440 440
 	*/
441
-    private function setAccessToken($data){		
442
-        $token = is_object($data) ? $data->access_token : $data;
443
-        $this->access_token = $token;
444
-    }
441
+	private function setAccessToken($data){		
442
+		$token = is_object($data) ? $data->access_token : $data;
443
+		$this->access_token = $token;
444
+	}
445 445
 	
446 446
 	/*
447 447
 	* Getter: User Access Token
448 448
 	*
449 449
 	* @return string
450 450
 	*/
451
-    private function getAccessToken(){
452
-        return $this->access_token;
453
-    }
451
+	private function getAccessToken(){
452
+		return $this->access_token;
453
+	}
454 454
 		
455 455
 	/*
456 456
 	* Get a string containing the version of the library.
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 * @version 1.0
21 21
 * @license: GNU GPL v3 License
22 22
 */
23
-class Instagram{
23
+class Instagram {
24 24
 	/*
25 25
 	* Library Version
26 26
 	*/
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	* I/p: Instagram Configuration Data
114 114
 	* @return: void
115 115
 	*/
116
-	public function __construct($config){		
116
+	public function __construct($config) {		
117 117
 		if (is_object($config)) {
118 118
 			$this->setClientId($config->ClientId);
119 119
 			$this->setClientSecret($config->ClientSecret);
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	*
139 139
 	* @return string
140 140
 	*/
141
-	public function getUrl($path, array $parameters){		
141
+	public function getUrl($path, array $parameters) {		
142 142
 		if (is_array($parameters)) {			
143 143
 			if (isset($parameters['scope']) and count(array_diff($parameters['scope'], $this->default_scopes)) === 0) {
144 144
 				$this->scopes = $parameters['scope']; 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 				throw new InstagramException("Missing or Invalid Scope permission used");
147 147
 			}
148 148
 			
149
-			$query = 'client_id='. $this->getClientId() .'&redirect_uri='. urlencode($this->getCallbackUrl()) .'&response_type=code';
149
+			$query = 'client_id='.$this->getClientId().'&redirect_uri='.urlencode($this->getCallbackUrl()).'&response_type=code';
150 150
 			
151 151
 			if (isset($this->scopes)) {
152 152
 				$scope = urlencode(str_replace(",", " ", implode(",", $parameters['scope'])));
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	* @param string $code - Oauth2 Code returned with callback url after successfull login
167 167
 	* @param boolean $token - true will return only access token
168 168
 	*/
169
-	public function getToken($path, $code, $token = false){
169
+	public function getToken($path, $code, $token = false) {
170 170
 		$options = array(
171 171
 			"grant_type" => "authorization_code",
172 172
 			"client_id" => $this->getClientId(),
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 		$this->execute($path, $options, 'POST');
186 186
 		
187 187
 		if (isset($this->response->code)) {
188
-			throw new InstagramException("return status code: ". $this->response->code ." type: ". $this->response->error_type ." message: ". $this->response->error_message );
188
+			throw new InstagramException("return status code: ".$this->response->code." type: ".$this->response->error_type." message: ".$this->response->error_message);
189 189
 		}
190 190
 				
191 191
 		$this->setAccessToken($this->response);
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 	* @param array|string $options in case of POST [optional]
201 201
 	* @param string $method GET|POST
202 202
 	*/
203
-	protected function execute($endpoint, $options, $method = 'GET'){
203
+	protected function execute($endpoint, $options, $method = 'GET') {
204 204
 		
205
-		if( !isset($this->client) ){
205
+		if (!isset($this->client)) {
206 206
 			$this->client = new Client([
207 207
 				'base_uri' => self::API_HOST
208 208
 			]);
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	*
262 262
 	* return string (Signature)
263 263
 	*/
264
-	protected function secureRequest($endpoint, $auth, $params){	
264
+	protected function secureRequest($endpoint, $auth, $params) {	
265 265
 		if (!is_array($params)) {
266 266
 			$params = array();	
267 267
 		}
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 		$signature = $endpoint;
275 275
 		ksort($params);
276 276
 		
277
-		foreach($params as $key => $value){
277
+		foreach ($params as $key => $value) {
278 278
 			$signature .= "|$key=$value";	
279 279
 		}
280 280
 					
@@ -286,13 +286,13 @@  discard block
 block discarded – undo
286 286
 	*
287 287
 	* return mixed
288 288
 	*/
289
-	public function request($path, $params = null, $method = 'GET'){
289
+	public function request($path, $params = null, $method = 'GET') {
290 290
 		if ($this->x_rate_limit_remaining < 1) {
291 291
 			throw new InstagramException("You have reached Instagram API Rate Limit");
292 292
 			exit();
293 293
 		} else {
294 294
 			$data = array();
295
-			if ($params != null){
295
+			if ($params != null) {
296 296
 				$data = $params;	
297 297
 			}
298 298
 			
@@ -305,30 +305,30 @@  discard block
 block discarded – undo
305 305
 					exit();
306 306
 				}
307 307
 				
308
-				$authentication_method = '?access_token=' . $this->access_token;
308
+				$authentication_method = '?access_token='.$this->access_token;
309 309
 				// Need to remove the access_token from $params array
310 310
 				unset($params['access_token']);				
311 311
 			} else {
312
-				$authentication_method = '?client_id=' . $this->getClientId();
312
+				$authentication_method = '?client_id='.$this->getClientId();
313 313
 				
314 314
 				$param = null;
315 315
 				
316
-				if (isset($params) and is_array($params) ) {
317
-					$param = '&' . http_build_query($params);	
316
+				if (isset($params) and is_array($params)) {
317
+					$param = '&'.http_build_query($params);	
318 318
 				}
319 319
 			}
320 320
 			
321 321
 			// This portion needs modification
322 322
 			$param = null;
323 323
 				
324
-			if (isset($params) and is_array($params) ) {
325
-				$param = '&' . http_build_query($params);	
324
+			if (isset($params) and is_array($params)) {
325
+				$param = '&'.http_build_query($params);	
326 326
 			}
327 327
 			
328
-			$endpoint = self::API_VERSION. $path . $authentication_method . (('GET' === $method) ? $param : null);
328
+			$endpoint = self::API_VERSION.$path.$authentication_method.(('GET' === $method) ? $param : null);
329 329
 			
330 330
 			if ($this->secure) {
331
-				$endpoint .= (strstr($endpoint, '?') ? '&' : '?') . 'sig=' . $this->secureRequest($path, $authentication_method, $data);
331
+				$endpoint .= (strstr($endpoint, '?') ? '&' : '?').'sig='.$this->secureRequest($path, $authentication_method, $data);
332 332
 			}
333 333
 						
334 334
 			$this->execute($endpoint, $data);
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	* @param: string $clientId
343 343
 	* @return: void
344 344
 	*/
345
-	public function setClientId($clientId){
345
+	public function setClientId($clientId) {
346 346
 		$this->client_id = $clientId;	
347 347
 	}
348 348
 	
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	* Getter: Client Id
351 351
 	* @return: string
352 352
 	*/
353
-	public function getClientId(){
353
+	public function getClientId() {
354 354
 		return $this->client_id;	
355 355
 	}
356 356
 	
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	* @param: string $secret
360 360
 	* @return: void
361 361
 	*/
362
-	public function setClientSecret($secret){
362
+	public function setClientSecret($secret) {
363 363
 		$this->client_secret = $secret;	
364 364
 	}
365 365
 	
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 	* Getter: Client Id
368 368
 	* @return: string
369 369
 	*/
370
-	public function getClientSecret(){
370
+	public function getClientSecret() {
371 371
 		return $this->client_secret;	
372 372
 	}
373 373
 	
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	* @param: string $url
377 377
 	* @return: void
378 378
 	*/
379
-	public function setCallbackUrl($url){
379
+	public function setCallbackUrl($url) {
380 380
 		$this->callback_url = $url;	
381 381
 	}
382 382
 	
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 	* Getter: Callback Url
385 385
 	* @return: string
386 386
 	*/
387
-	public function getCallbackUrl(){
387
+	public function getCallbackUrl() {
388 388
 		return $this->callback_url;	
389 389
 	}
390 390
 	
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 	* @param: integer|decimal|long $time
394 394
 	* @return: void
395 395
 	*/
396
-	public function setTimeout($time = 90){
396
+	public function setTimeout($time = 90) {
397 397
 		$this->timeout = $time;	
398 398
 	}
399 399
 	
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 	* Getter: Get Curl Timeout
402 402
 	* @return: integer|decimal|long
403 403
 	*/
404
-	public function getTimeout(){
404
+	public function getTimeout() {
405 405
 		return $this->timeout;	
406 406
 	}
407 407
 	
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	* @param: integer|decimal|long $time
411 411
 	* @return: void
412 412
 	*/
413
-	public function setConnectTimeout($time = 20){
413
+	public function setConnectTimeout($time = 20) {
414 414
 		$this->connect_timeout = $time;	
415 415
 	}
416 416
 	
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 	* Getter: Get Curl connect timeout
419 419
 	* @return: integer|decimal|long
420 420
 	*/
421
-	public function getConnectTimeout(){
421
+	public function getConnectTimeout() {
422 422
 		return $this->connect_timeout;	
423 423
 	}
424 424
 	
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 	* @param: boolean $secure
428 428
 	* @return: void
429 429
 	*/
430
-	public function setRequestSecure($secure){
430
+	public function setRequestSecure($secure) {
431 431
 		$this->secure = $secure;	
432 432
 	}	
433 433
 	
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 	*
439 439
 	* @return void
440 440
 	*/
441
-    private function setAccessToken($data){		
441
+    private function setAccessToken($data) {		
442 442
         $token = is_object($data) ? $data->access_token : $data;
443 443
         $this->access_token = $token;
444 444
     }
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 	*
449 449
 	* @return string
450 450
 	*/
451
-    private function getAccessToken(){
451
+    private function getAccessToken() {
452 452
         return $this->access_token;
453 453
     }
454 454
 		
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 	*
458 458
 	* @return string
459 459
 	*/
460
-	public function getLibraryVersion(){
460
+	public function getLibraryVersion() {
461 461
 		return self::VERSION;
462 462
 	}
463 463
 }
Please login to merge, or discard this patch.
src/InstagramException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Haridarshan\Instagram;
3 3
 
4
-class InstagramException extends \Exception{
4
+class InstagramException extends \Exception {
5 5
 	
6 6
 }
Please login to merge, or discard this patch.