Completed
Push — master ( 8f8221...a2309d )
by Haridarshan
02:33
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   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -73,12 +73,12 @@  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
80
-	 * 
81
-	 * @todo validate callback url
78
+     *
79
+     * @throws InstagramException|InvalidArgumentException
80
+     * 
81
+     * @todo validate callback url
82 82
      */
83 83
     public function __construct(array $config = [])
84 84
     {
@@ -86,19 +86,19 @@  discard block
 block discarded – undo
86 86
             throw new InstagramException('Invalid Instagram Configuration data');
87 87
         }
88 88
 		
89
-		if (!$config['ClientId']) {
89
+        if (!$config['ClientId']) {
90 90
             throw new InstagramException('Missing "ClientId" key not supplied in config');
91 91
         }
92 92
 		
93
-		if (!$config['ClientSecret']) {
93
+        if (!$config['ClientSecret']) {
94 94
             throw new InstagramException('Missing "ClientSecret" key not supplied in config');
95 95
         }
96 96
 		
97
-		if (!$config['Callback']) {
97
+        if (!$config['Callback']) {
98 98
             throw new InstagramException('Missing "Callback" key not supplied in config');
99 99
         }
100 100
 		
101
-		$this->app = new InstagramApp($config['ClientId'], $config['ClientSecret']);	
101
+        $this->app = new InstagramApp($config['ClientId'], $config['ClientSecret']);	
102 102
 		
103 103
         $this->setCallbackUrl($config['Callback']);
104 104
         $this->state = isset($config['State']) ? $config['State'] : substr(md5(rand()), 0, 7);
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         $this->client = HelperFactory::getInstance()->client(Constants::API_HOST);
107 107
     }
108 108
 	
109
-	/**
109
+    /**
110 110
      * Returns InstagramApp entity.
111 111
      *
112 112
      * @return InstagramApp
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 	
119 119
     /**
120 120
      * Make URLs for user browser navigation
121
-	 *
121
+     *
122 122
      * @param array  $parameters
123
-	 *
123
+     *
124 124
      * @return string
125
-	 *
126
-	 * @throws InstagramException
125
+     *
126
+     * @throws InstagramException
127 127
      */
128 128
     public function getLoginUrl(array $parameters)
129 129
     {
@@ -136,21 +136,21 @@  discard block
 block discarded – undo
136 136
 		
137 137
         $this->scopes = $parameters['scope'];
138 138
 		
139
-		$loginUrl = new LoginUrl(
140
-			$this->getApp(),
141
-			$this->getCallbackUrl(),
142
-			$this->getState(),
143
-			$this->scopes
144
-		);
139
+        $loginUrl = new LoginUrl(
140
+            $this->getApp(),
141
+            $this->getCallbackUrl(),
142
+            $this->getState(),
143
+            $this->scopes
144
+        );
145 145
 		
146
-		return $loginUrl->loginUrl();
146
+        return $loginUrl->loginUrl();
147 147
     }
148 148
 	
149 149
     /**
150 150
      * Get the Oauth Access Token of a user from callback code
151
-	 *
151
+     *
152 152
      * @param string $code - Oauth2 Code returned with callback url after successfull login
153
-	 *
153
+     *
154 154
      * @return InstagramOAuth
155 155
      */
156 156
     public function oauth($code)
@@ -164,20 +164,20 @@  discard block
 block discarded – undo
164 164
             "state" => $this->state
165 165
         );
166 166
 		
167
-		$response = HelperFactory::getInstance()->request($this->client, Constants::API_TOKEN, $options, 'POST');
167
+        $response = HelperFactory::getInstance()->request($this->client, Constants::API_TOKEN, $options, 'POST');
168 168
 		
169 169
         $this->oauthResponse = new InstagramOAuth(
170
-			json_decode($response->getBody()->getContents())
171
-		);
170
+            json_decode($response->getBody()->getContents())
171
+        );
172 172
 		
173 173
         return $this->oauthResponse;
174 174
     }
175 175
 	
176 176
     /**
177 177
      * Setter: Callback Url
178
-	 *
178
+     *
179 179
      * @param string $url
180
-	 *
180
+     *
181 181
      * @return void
182 182
      */
183 183
     public function setCallbackUrl($url)
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	
188 188
     /**
189 189
      * Getter: Callback Url
190
-	 *
190
+     *
191 191
      * @return string
192 192
      */
193 193
     public function getCallbackUrl()
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	
198 198
     /**
199 199
      * Get InstagramOAuth
200
-	 *
200
+     *
201 201
      * @return InstagramOAuth
202 202
      */
203 203
     public function getOAuth()
@@ -206,16 +206,16 @@  discard block
 block discarded – undo
206 206
             return $this->oauthResponse;
207 207
         }
208 208
 		
209
-		$accessToken = new stdClass;
210
-		$accessToken->access_token = null;
209
+        $accessToken = new stdClass;
210
+        $accessToken->access_token = null;
211 211
 		
212 212
         $this->oauthResponse = new InstagramOAuth($accessToken);
213 213
         return $this->oauthResponse;
214 214
     }
215 215
 	
216 216
     /**
217
-	 * Get Http Client
218
-	 *
217
+     * Get Http Client
218
+     *
219 219
      * @return Client
220 220
      */
221 221
     public function getHttpClient()
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
 	
226 226
     /**
227 227
      * Set User Access Token
228
-	 *
228
+     *
229 229
      * @param string $token
230
-	 *
230
+     *
231 231
      * @return void
232 232
      */
233 233
     public function setAccessToken($token)
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	
240 240
     /**
241 241
      * Get state value
242
-	 *
242
+     *
243 243
      * @return string|mixed
244 244
      */
245 245
     public function getState()
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
     /**
251 251
      * Get a string containing the version of the library.
252
-	 *
252
+     *
253 253
      * @return string
254 254
      */
255 255
     public function getLibraryVersion()
Please login to merge, or discard this patch.