Completed
Push — master ( e26d56...fcd15c )
by Haridarshan
02:39
created
src/InstagramApp.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
  */
42 42
 class InstagramApp
43 43
 {
44
-	/**
44
+    /**
45 45
      * @var string Instagram App ID.
46 46
      */
47 47
     protected $id;
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     protected $secret;
53 53
 	
54
-	/**
54
+    /**
55 55
      * @param string $id
56 56
      * @param string $secret
57 57
      *
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
             throw new InstagramException('The "client_id" must be formatted as a string.');
64 64
         }
65 65
 		
66
-		if (!is_string($secret)) {
66
+        if (!is_string($secret)) {
67 67
             throw new InstagramException('The "client_secret" must be formatted as a string.');
68 68
         }
69 69
 		
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         $this->secret = $secret;
72 72
     }
73 73
 	
74
-	/**
74
+    /**
75 75
      * Returns the app ID.
76 76
      *
77 77
      * @return string
Please login to merge, or discard this patch.
src/LoginUrl.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -39,43 +39,43 @@
 block discarded – undo
39 39
  */
40 40
 class LoginUrl
41 41
 {
42
-	/** @var InstagramApp */
43
-	protected $app;
42
+    /** @var InstagramApp */
43
+    protected $app;
44 44
 	
45
-	/** @var string */
46
-	protected $callback;
45
+    /** @var string */
46
+    protected $callback;
47 47
 	
48
-	/** @var string */
49
-	protected $state; 
48
+    /** @var string */
49
+    protected $state; 
50 50
 	
51
-	/** @var array */
52
-	protected $scopes;
51
+    /** @var array */
52
+    protected $scopes;
53 53
 	
54
-	/**
54
+    /**
55 55
      * LoginUrl constructor
56
-	 * 
56
+     * 
57 57
      * @param InstagramApp $app
58 58
      * @param string $callback
59 59
      * @param string $state
60 60
      * @param array $scopes
61 61
      */
62
-	public function __construct(InstagramApp $app, $callback, $state, $scopes)
63
-	{
64
-		$this->app = $app;	
65
-		$this->callback = $callback;	
66
-		$this->state = $state;	
67
-		$this->scopes = $scopes;	
68
-	}
62
+    public function __construct(InstagramApp $app, $callback, $state, $scopes)
63
+    {
64
+        $this->app = $app;	
65
+        $this->callback = $callback;	
66
+        $this->state = $state;	
67
+        $this->scopes = $scopes;	
68
+    }
69 69
 	
70
-	/**
70
+    /**
71 71
      * Creates login url
72
-	 * 
73
-	 * @return string
72
+     * 
73
+     * @return string
74 74
      */
75
-	public function loginUrl()
76
-	{
77
-		$query = 'client_id='.$this->app->getId().'&redirect_uri='.urlencode($this->callback).'&response_type=code&state='.$this->state;
75
+    public function loginUrl()
76
+    {
77
+        $query = 'client_id='.$this->app->getId().'&redirect_uri='.urlencode($this->callback).'&response_type=code&state='.$this->state;
78 78
         $query .= isset($this->scopes) ? '&scope='.urlencode(str_replace(",", " ", implode(",", $this->scopes))) : '';
79 79
         return sprintf('%s%s?%s', Constants::API_HOST, Constants::API_AUTH, $query);
80
-	}
80
+    }
81 81
 }
Please login to merge, or discard this patch.
src/HelperFactory.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
     
86 86
     /** 
87 87
      * Factory Client method to create \GuzzleHttp\Client object
88
-	 * 
88
+     * 
89 89
      * @param string $uri
90
-	 * 
90
+     * 
91 91
      * @return Client
92 92
      */
93 93
     public function client($uri)
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
     }
99 99
 	
100 100
     /**
101
-	 * Sends request to Instagram Api Endpoints
102
-	 * 
101
+     * Sends request to Instagram Api Endpoints
102
+     * 
103 103
      * @param Client $client
104 104
      * @param string $endpoint
105 105
      * @param array|string $options
106 106
      * @param string $method
107
-	 * 
107
+     * 
108 108
      * @return Response
109
-	 * 
109
+     * 
110 110
      * @throws InstagramOAuthException|InstagramException
111 111
      */
112 112
     public function request(Client $client, $endpoint, $options, $method = 'GET')
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
     
123 123
     /**
124 124
      * Create body for Guzzle client request
125
-	 * 
125
+     * 
126 126
      * @param array|null|string $options
127 127
      * @param string $method GET|POST
128
-	 * 
128
+     * 
129 129
      * @return string|mixed
130 130
      */
131 131
     protected static function createBody($options, $method)
@@ -158,13 +158,13 @@  discard block
 block discarded – undo
158 158
     }
159 159
     
160 160
     /** 
161
-	 * Throw required Exception 
162
-	 * 
161
+     * Throw required Exception 
162
+     * 
163 163
      * @param \stdClass $object
164
-	 * @param ClientException $exMessage
165
-	 * 
166
-	 * @return void
167
-	 *
164
+     * @param ClientException $exMessage
165
+     * 
166
+     * @return void
167
+     *
168 168
      * @throws InstagramOAuthException|InstagramException
169 169
      */
170 170
     protected static function throwException(\stdClass $object, ClientException $exMessage)
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
     }
186 186
 	
187 187
     /**
188
-	 * Creates Exception Message
189
-	 * 
190
-	 * @param \stdClass $object
191
-	 * 
192
-	 * @return array
193
-	 */
188
+     * Creates Exception Message
189
+     * 
190
+     * @param \stdClass $object
191
+     * 
192
+     * @return array
193
+     */
194 194
     protected static function createExceptionMessage(\stdClass $object)
195 195
     {
196 196
         $message = array();		
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
         // a factory clone should never be invoked
212 212
     }
213 213
 	
214
-	/**
214
+    /**
215 215
      * Private unserialize method to prevent unserializing of the *HelperFactory	*
216 216
      * instance.
217 217
      *
Please login to merge, or discard this patch.
src/InstagramRequest.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     
73 73
     /**
74 74
      * Create the request and execute it to get the response
75
-	 * 
75
+     * 
76 76
      * @param Instagram $instagram
77 77
      * @param string $path
78 78
      * @param array $params
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
     
89 89
     /**
90 90
      * Execute the Instagram Request
91
-	 * 
91
+     * 
92 92
      * @param void
93
-	 * 
93
+     * 
94 94
      * @return InstagramResponse
95
-	 * 
96
-	 * @throws InstagramResponseException
95
+     * 
96
+     * @throws InstagramResponseException
97 97
      */
98 98
     protected function execute()
99 99
     {
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     
113 113
     /**
114 114
      * Check Access Token is present. If not throw InstagramRequestException
115
-	 * 
115
+     * 
116 116
      * @throws InstagramRequestException
117 117
      */
118 118
     protected function isAccessTokenPresent()
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     
125 125
     /**
126 126
      * Get Response
127
-	 * 
127
+     * 
128 128
      * @return InstagramResponse
129 129
      */
130 130
     public function getResponse()
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
     
144 144
     /**
145 145
      * Check whether api rate limit is reached or not
146
-	 * 
146
+     * 
147 147
      * @throws InstagramThrottleException
148 148
      */
149 149
     private function isRateLimitReached()
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
     
156 156
     /**
157 157
      * Secure API Request by using endpoint, paramters and API secret
158
-	 * 
159
-	 * @see https://www.instagram.com/developer/secure-api-requests/
158
+     * 
159
+     * @see https://www.instagram.com/developer/secure-api-requests/
160 160
      *
161 161
      * @param InstagramApp $app
162 162
      * @param string $endpoint
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
     }
176 176
     
177 177
     /**
178
-	 * Get Api Rate Limit
179
-	 * 
178
+     * Get Api Rate Limit
179
+     * 
180 180
      * @return int
181 181
      */
182 182
     public function getRateLimit()
Please login to merge, or discard this patch.
src/InstagramResponse.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -59,12 +59,12 @@  discard block
 block discarded – undo
59 59
     protected $body;
60 60
 	
61 61
     /**
62
-	 * InstagramResponse Entity
63
-	 * 
64
-	 * @param Response $response
65
-	 * 
66
-	 * @throws InstagramResponseException
67
-	 */
62
+     * InstagramResponse Entity
63
+     * 
64
+     * @param Response $response
65
+     * 
66
+     * @throws InstagramResponseException
67
+     */
68 68
     public function __construct(Response $response)
69 69
     {
70 70
         if (!$response instanceof Response) {
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
     }
75 75
     
76 76
     /**
77
-	 * Set Values to the class members
78
-	 * 
79
-	 * @param Response $response
80
-	 * 
81
-	 * @return void
82
-	 */
77
+     * Set Values to the class members
78
+     * 
79
+     * @param Response $response
80
+     * 
81
+     * @return void
82
+     */
83 83
     private function setParams(Response $response)
84 84
     {
85 85
         $this->protocol = $response->getProtocolVersion();
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
         $this->extractBodyParts();
90 90
     }
91 91
 	
92
-	/**
93
-	 * Extract Body Parts from the response
94
-	 * 
95
-	 * @return void
96
-	 */
92
+    /**
93
+     * Extract Body Parts from the response
94
+     * 
95
+     * @return void
96
+     */
97 97
     private function extractBodyParts()
98 98
     {
99 99
         if (isset($this->body->pagination)) {
@@ -110,102 +110,102 @@  discard block
 block discarded – undo
110 110
     }
111 111
     
112 112
     /**
113
-	 * Get response
114
-	 * 
115
-	 * @return object|string 
116
-	 */
113
+     * Get response
114
+     * 
115
+     * @return object|string 
116
+     */
117 117
     public function getBody()
118 118
     {
119 119
         return $this->body;
120 120
     }
121 121
     
122 122
     /** 
123
-	 * Get Status Code
124
-	 * 
125
-	 * @return int
126
-	 */
123
+     * Get Status Code
124
+     * 
125
+     * @return int
126
+     */
127 127
     public function getStatusCode()
128 128
     {
129 129
         return $this->statusCode;
130 130
     }
131 131
     
132 132
     /**
133
-	 * Get specific header
134
-	 * 
135
-	 * @param string $header
136
-	 * 
137
-	 * @retrun string 
138
-	 */
133
+     * Get specific header
134
+     * 
135
+     * @param string $header
136
+     * 
137
+     * @retrun string 
138
+     */
139 139
     public function getHeader($header)
140 140
     {
141 141
         return isset($this->headers[$header]) ? $this->headers[$header] : [];
142 142
     }
143 143
 	
144 144
     /**
145
-	 * Get all headers
146
-	 * 
147
-	 * @retrun array 
148
-	 */
145
+     * Get all headers
146
+     * 
147
+     * @retrun array 
148
+     */
149 149
     public function getHeaders()
150 150
     {
151 151
         return $this->headers;
152 152
     }
153 153
 	
154 154
     /**
155
-	 * Get data from body
156
-	 * 
157
-	 * @return object
158
-	 */
155
+     * Get data from body
156
+     * 
157
+     * @return object
158
+     */
159 159
     public function getData()
160 160
     {
161 161
         return $this->data;
162 162
     }
163 163
 	
164 164
     /**
165
-	 * Get Meta data
166
-	 * 
167
-	 * @return object
168
-	 */
165
+     * Get Meta data
166
+     * 
167
+     * @return object
168
+     */
169 169
     public function getMetaData()
170 170
     {
171 171
         return $this->metaData;
172 172
     }
173 173
 	
174 174
     /**
175
-	 * Get Meta data
176
-	 * 
177
-	 * @return object
178
-	 */
175
+     * Get Meta data
176
+     * 
177
+     * @return object
178
+     */
179 179
     public function getPagination()
180 180
     {
181 181
         return $this->pagination;
182 182
     }
183 183
 	
184 184
     /**
185
-	 * Is Meta Data Present
186
-	 * 
187
-	 * @return bool
188
-	 */
185
+     * Is Meta Data Present
186
+     * 
187
+     * @return bool
188
+     */
189 189
     public function isMetaDataSet()
190 190
     {
191 191
         return $this->isMetaData;
192 192
     }
193 193
 	
194 194
     /**
195
-	 * Is Pagination present
196
-	 * 
197
-	 * @return bool
198
-	 */
195
+     * Is Pagination present
196
+     * 
197
+     * @return bool
198
+     */
199 199
     public function isPaginationSet()
200 200
     {
201 201
         return $this->isPagination;
202 202
     }
203 203
 	
204 204
     /**
205
-	 * Get Protocol version
206
-	 * 
207
-	 * @return string
208
-	 */
205
+     * Get Protocol version
206
+     * 
207
+     * @return string
208
+     */
209 209
     public function getProtocol()
210 210
     {
211 211
         return $this->protocol;
Please login to merge, or discard this patch.
src/InstagramOAuth.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
     protected $user;
50 50
     
51 51
     /** 
52
-	 * InstagramOAuth Entity 
53
-	 * 
52
+     * InstagramOAuth Entity 
53
+     * 
54 54
      * @param stdClass $oauth
55
-	 * 
55
+     * 
56 56
      * @throws InstagramOAuthException
57 57
      */
58 58
     public function __construct(stdClass $oauth)
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     
68 68
     /**
69 69
      * Get Access Token
70
-	 * 
70
+     * 
71 71
      * @return string
72 72
      */
73 73
     public function getAccessToken()
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
     
78 78
     /**
79 79
      * Set Access Token
80
-	 * 
80
+     * 
81 81
      * @param string $token
82
-	 * 
82
+     * 
83 83
      * @return void
84 84
      */
85 85
     public function setAccessToken($token)
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     
90 90
     /**
91 91
      * If AccessToken is set return true else false
92
-	 * 
92
+     * 
93 93
      * @return bool
94 94
      */
95 95
     public function isAccessTokenSet()
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     
100 100
     /**
101 101
      * Get User Info
102
-	 * 
102
+     * 
103 103
      * @return object
104 104
      */
105 105
     public function getUserInfo()
Please login to merge, or discard this patch.
src/Instagram.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
     /**
74 74
      * Default Constructor
75 75
      * Instagram Configuration Data
76
-	 *
76
+     *
77 77
      * @param array $config
78
-	 *
79
-	 * @throws InstagramException|InvalidArgumentException
78
+     *
79
+     * @throws InstagramException|InvalidArgumentException
80 80
      */
81 81
     public function __construct(array $config = [])
82 82
     {
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             throw new InstagramException('Invalid Instagram Configuration data');
85 85
         }
86 86
 		
87
-		$this->app = new InstagramApp($config['ClientId'], $config['ClientSecret']);	
87
+        $this->app = new InstagramApp($config['ClientId'], $config['ClientSecret']);	
88 88
 		
89 89
         $this->setCallbackUrl($config['Callback']);
90 90
         $this->state = isset($config['State']) ? $config['State'] : substr(md5(rand()), 0, 7);
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         $this->client = HelperFactory::getInstance()->client(Constants::API_HOST);
93 93
     }
94 94
 	
95
-	/**
95
+    /**
96 96
      * Returns InstagramApp entity.
97 97
      *
98 98
      * @return InstagramApp
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 	
105 105
     /**
106 106
      * Make URLs for user browser navigation
107
-	 *
107
+     *
108 108
      * @param array  $parameters
109
-	 *
109
+     *
110 110
      * @return string
111
-	 *
112
-	 * @throws InstagramException
111
+     *
112
+     * @throws InstagramException
113 113
      */
114 114
     public function getLoginUrl(array $parameters)
115 115
     {
@@ -122,21 +122,21 @@  discard block
 block discarded – undo
122 122
 		
123 123
         $this->scopes = $parameters['scope'];
124 124
 		
125
-		$loginUrl = new LoginUrl(
126
-			$this->getApp(),
127
-			$this->getCallbackUrl(),
128
-			$this->getState(),
129
-			$this->scopes
130
-		);
125
+        $loginUrl = new LoginUrl(
126
+            $this->getApp(),
127
+            $this->getCallbackUrl(),
128
+            $this->getState(),
129
+            $this->scopes
130
+        );
131 131
 		
132
-		return $loginUrl->loginUrl();
132
+        return $loginUrl->loginUrl();
133 133
     }
134 134
 	
135 135
     /**
136 136
      * Get the Oauth Access Token of a user from callback code
137
-	 *
137
+     *
138 138
      * @param string $code - Oauth2 Code returned with callback url after successfull login
139
-	 *
139
+     *
140 140
      * @return InstagramOAuth
141 141
      */
142 142
     public function oauth($code)
@@ -150,20 +150,20 @@  discard block
 block discarded – undo
150 150
             "state" => $this->state
151 151
         );
152 152
 		
153
-		$response = HelperFactory::getInstance()->request($this->client, Constants::API_TOKEN, $options, 'POST');
153
+        $response = HelperFactory::getInstance()->request($this->client, Constants::API_TOKEN, $options, 'POST');
154 154
 		
155 155
         $this->oauthResponse = new InstagramOAuth(
156
-			json_decode($response->getBody()->getContents())
157
-		);
156
+            json_decode($response->getBody()->getContents())
157
+        );
158 158
 		
159 159
         return $this->oauthResponse;
160 160
     }
161 161
 	
162 162
     /**
163 163
      * Setter: Callback Url
164
-	 *
164
+     *
165 165
      * @param string $url
166
-	 *
166
+     *
167 167
      * @return void
168 168
      */
169 169
     public function setCallbackUrl($url)
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	
174 174
     /**
175 175
      * Getter: Callback Url
176
-	 *
176
+     *
177 177
      * @return string
178 178
      */
179 179
     public function getCallbackUrl()
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	
184 184
     /**
185 185
      * Get InstagramOAuth
186
-	 *
186
+     *
187 187
      * @return InstagramOAuth
188 188
      */
189 189
     public function getOAuth()
@@ -192,16 +192,16 @@  discard block
 block discarded – undo
192 192
             return $this->oauthResponse;
193 193
         }
194 194
 		
195
-		$accessToken = new stdClass;
196
-		$accessToken->access_token = null;
195
+        $accessToken = new stdClass;
196
+        $accessToken->access_token = null;
197 197
 		
198 198
         $this->oauthResponse = new InstagramOAuth($accessToken);
199 199
         return $this->oauthResponse;
200 200
     }
201 201
 	
202 202
     /**
203
-	 * Get Http Client
204
-	 *
203
+     * Get Http Client
204
+     *
205 205
      * @return Client
206 206
      */
207 207
     public function getHttpClient()
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 	
212 212
     /**
213 213
      * Set User Access Token
214
-	 *
214
+     *
215 215
      * @param string $token
216
-	 *
216
+     *
217 217
      * @return void
218 218
      */
219 219
     public function setAccessToken($token)
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	
226 226
     /**
227 227
      * Get state value
228
-	 *
228
+     *
229 229
      * @return string|mixed
230 230
      */
231 231
     public function getState()
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 
236 236
     /**
237 237
      * Get a string containing the version of the library.
238
-	 *
238
+     *
239 239
      * @return string
240 240
      */
241 241
     public function getLibraryVersion()
Please login to merge, or discard this patch.