@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param $EntryPoint - EPInterface Class Name |
32 | 32 | * @return $this |
33 | 33 | */ |
34 | - public function registerEntryPoint($function,$EntryPoint); |
|
34 | + public function registerEntryPoint($function, $EntryPoint); |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Login to the configured SugarCRM server |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param $client_id |
58 | 58 | * @return boolean |
59 | 59 | */ |
60 | - public static function storeToken($token,$client_id); |
|
60 | + public static function storeToken($token, $client_id); |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Get an SDK Clients authentication Token from Storage |
@@ -39,7 +39,7 @@ |
||
39 | 39 | public static function getSDKEntryPointRegistry(){ |
40 | 40 | $entryPoints = array(); |
41 | 41 | require __DIR__.DIRECTORY_SEPARATOR.'registry.php'; |
42 | - foreach ($entryPoints as $funcName => $className) { |
|
42 | + foreach ($entryPoints as $funcName => $className){ |
|
43 | 43 | $className = "SugarAPI\\SDK\\EntryPoint\\" . $className; |
44 | 44 | $entryPoints[$funcName] = $className; |
45 | 45 | } |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | * @return string |
16 | 16 | */ |
17 | 17 | public static function configureAPIURL($instance){ |
18 | - if (strpos($instance,"http")===FALSE){ |
|
18 | + if (strpos($instance, "http")===FALSE){ |
|
19 | 19 | $instance = "http://".$instance; |
20 | 20 | } |
21 | - if (strpos($instance,"rest/v10")!==FALSE){ |
|
21 | + if (strpos($instance, "rest/v10")!==FALSE){ |
|
22 | 22 | $instance = str_replace("rest/v10", "", $instance); |
23 | 23 | } |
24 | 24 | return rtrim($instance, "/").self::API_URL; |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | public static function getSDKEntryPointRegistry(){ |
40 | 40 | $entryPoints = array(); |
41 | 41 | require __DIR__.DIRECTORY_SEPARATOR.'registry.php'; |
42 | - foreach ($entryPoints as $funcName => $className) { |
|
43 | - $className = "SugarAPI\\SDK\\EntryPoint\\" . $className; |
|
42 | + foreach ($entryPoints as $funcName => $className){ |
|
43 | + $className = "SugarAPI\\SDK\\EntryPoint\\".$className; |
|
44 | 44 | $entryPoints[$funcName] = $className; |
45 | 45 | } |
46 | 46 | return $entryPoints; |
@@ -6,15 +6,15 @@ |
||
6 | 6 | |
7 | 7 | class OAuth2Token extends AbstractPostEntryPoint { |
8 | 8 | |
9 | - protected $_AUTH_REQUIRED = false; |
|
9 | + protected $_AUTH_REQUIRED = FALSE; |
|
10 | 10 | protected $_URL = 'oauth2/token'; |
11 | 11 | protected $_REQUIRED_DATA = array( |
12 | - 'username' => null, |
|
13 | - 'password' => null, |
|
12 | + 'username' => NULL, |
|
13 | + 'password' => NULL, |
|
14 | 14 | 'grant_type' => 'password', |
15 | - 'client_id' => null, |
|
16 | - 'client_secret' => null, |
|
17 | - 'platform' => null |
|
15 | + 'client_id' => NULL, |
|
16 | + 'client_secret' => NULL, |
|
17 | + 'platform' => NULL |
|
18 | 18 | ); |
19 | 19 | protected $_DATA_TYPE = 'array'; |
20 | 20 |
@@ -17,7 +17,7 @@ |
||
17 | 17 | /** |
18 | 18 | * @inheritdoc |
19 | 19 | */ |
20 | - public function getBody($asArray = true){ |
|
20 | + public function getBody($asArray = TRUE){ |
|
21 | 21 | return json_decode($this->body, $asArray); |
22 | 22 | } |
23 | 23 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * Whether or not Authentication is Required |
45 | 45 | * @var bool |
46 | 46 | */ |
47 | - protected $_AUTH_REQUIRED = true; |
|
47 | + protected $_AUTH_REQUIRED = TRUE; |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * The URL for the EntryPoint |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | if (strpos($UrlArray[0],"$") !== FALSE){ |
320 | 320 | throw new InvalidURLException(get_called_class(),"Configured URL is ".$this->Url); |
321 | 321 | } |
322 | - return true; |
|
322 | + return TRUE; |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | if (!empty($this->_REQUIRED_DATA)){ |
335 | 335 | $this->verifyRequiredData(); |
336 | 336 | } |
337 | - return true; |
|
337 | + return TRUE; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | /** |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | if (gettype($this->Data) !== $this->_DATA_TYPE) { |
347 | 347 | throw new RequiredDataException(get_called_class(),"Valid DataType is {$this->_DATA_TYPE}"); |
348 | 348 | } |
349 | - return true; |
|
349 | + return TRUE; |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | if (count($errors)>0){ |
365 | 365 | throw new RequiredDataException(get_called_class(),"Missing data for ".implode(",",$errors)); |
366 | 366 | } |
367 | - return true; |
|
367 | + return TRUE; |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | protected $accessToken; |
97 | 97 | |
98 | 98 | |
99 | - public function __construct($baseUrl,array $options = array()){ |
|
99 | + public function __construct($baseUrl, array $options = array()){ |
|
100 | 100 | $this->baseUrl = $baseUrl; |
101 | 101 | |
102 | - if (!empty($options)) { |
|
102 | + if (!empty($options)){ |
|
103 | 103 | $this->setOptions($options); |
104 | 104 | } |
105 | 105 | $this->configureURL(); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | /** |
127 | 127 | * @inheritdoc |
128 | 128 | */ |
129 | - public function setAuth($accessToken) { |
|
129 | + public function setAuth($accessToken){ |
|
130 | 130 | $this->accessToken = $accessToken; |
131 | 131 | return $this; |
132 | 132 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | /** |
135 | 135 | * @inheritdoc |
136 | 136 | */ |
137 | - public function setUrl($url) { |
|
137 | + public function setUrl($url){ |
|
138 | 138 | $this->Url = $url; |
139 | 139 | return $this; |
140 | 140 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | /** |
143 | 143 | * @inheritdoc |
144 | 144 | */ |
145 | - public function setRequest(RequestInterface $Request) { |
|
145 | + public function setRequest(RequestInterface $Request){ |
|
146 | 146 | $this->Request = $Request; |
147 | 147 | return $this; |
148 | 148 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | /** |
151 | 151 | * @inheritdoc |
152 | 152 | */ |
153 | - public function setResponse(ResponseInterface $Response) { |
|
153 | + public function setResponse(ResponseInterface $Response){ |
|
154 | 154 | $this->Response = $Response; |
155 | 155 | return $this; |
156 | 156 | } |
@@ -198,14 +198,14 @@ discard block |
||
198 | 198 | * @throws InvalidURLException |
199 | 199 | */ |
200 | 200 | public function execute($data = NULL){ |
201 | - $data = ($data === NULL?$this->Data:$data); |
|
201 | + $data = ($data===NULL?$this->Data:$data); |
|
202 | 202 | $this->configureData($data); |
203 | - if (is_object($this->Request)) { |
|
203 | + if (is_object($this->Request)){ |
|
204 | 204 | $this->configureRequest(); |
205 | 205 | $this->Request->send(); |
206 | 206 | $this->configureResponse(); |
207 | 207 | }else{ |
208 | - throw new InvalidRequestException(get_called_class(),"Request property not configured"); |
|
208 | + throw new InvalidRequestException(get_called_class(), "Request property not configured"); |
|
209 | 209 | } |
210 | 210 | return $this; |
211 | 211 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | /** |
214 | 214 | * @inheritdoc |
215 | 215 | */ |
216 | - public function authRequired() { |
|
216 | + public function authRequired(){ |
|
217 | 217 | return $this->_AUTH_REQUIRED; |
218 | 218 | } |
219 | 219 | |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | * @throws RequiredDataException |
224 | 224 | */ |
225 | 225 | protected function configureRequest(){ |
226 | - if ($this->verifyUrl()) { |
|
226 | + if ($this->verifyUrl()){ |
|
227 | 227 | $this->Request->setURL($this->Url); |
228 | 228 | } |
229 | - if ($this->verifyData() && !empty($this->Data)) { |
|
229 | + if ($this->verifyData() && !empty($this->Data)){ |
|
230 | 230 | $this->Request->setBody($this->Data); |
231 | 231 | } |
232 | 232 | $this->configureAuth(); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * Configures the authentication header on the Request object |
248 | 248 | */ |
249 | 249 | protected function configureAuth(){ |
250 | - if ($this->authRequired()) { |
|
250 | + if ($this->authRequired()){ |
|
251 | 251 | $this->Request->addHeader('OAuth-Token', $this->accessToken); |
252 | 252 | } |
253 | 253 | } |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @var $data |
258 | 258 | */ |
259 | 259 | protected function configureData($data){ |
260 | - if (!empty($this->_REQUIRED_DATA)&&is_array($data)){ |
|
260 | + if (!empty($this->_REQUIRED_DATA) && is_array($data)){ |
|
261 | 261 | $data = $this->configureDefaultData($data); |
262 | 262 | } |
263 | 263 | $this->setData($data); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @return array |
270 | 270 | */ |
271 | 271 | protected function configureDefaultData(array $data){ |
272 | - foreach($this->_REQUIRED_DATA as $property => $value){ |
|
272 | + foreach ($this->_REQUIRED_DATA as $property => $value){ |
|
273 | 273 | if (!isset($data[$property]) && $value!==NULL){ |
274 | 274 | $data[$property] = $value; |
275 | 275 | } |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | */ |
285 | 285 | protected function configureURL(){ |
286 | 286 | $url = $this->_URL; |
287 | - if ($this->requiresOptions()) { |
|
288 | - foreach($this->Options as $key => $option){ |
|
289 | - $url = preg_replace('/(\$.*?[^\/]*)/',$option,$url,1); |
|
287 | + if ($this->requiresOptions()){ |
|
288 | + foreach ($this->Options as $key => $option){ |
|
289 | + $url = preg_replace('/(\$.*?[^\/]*)/', $option, $url, 1); |
|
290 | 290 | } |
291 | 291 | } |
292 | 292 | $url = $this->baseUrl.$url; |
@@ -299,9 +299,9 @@ discard block |
||
299 | 299 | * @throws InvalidURLException |
300 | 300 | */ |
301 | 301 | protected function verifyUrl(){ |
302 | - $UrlArray = explode("?",$this->Url); |
|
303 | - if (strpos($UrlArray[0],"$") !== FALSE){ |
|
304 | - throw new InvalidURLException(get_called_class(),"Configured URL is ".$this->Url); |
|
302 | + $UrlArray = explode("?", $this->Url); |
|
303 | + if (strpos($UrlArray[0], "$")!==FALSE){ |
|
304 | + throw new InvalidURLException(get_called_class(), "Configured URL is ".$this->Url); |
|
305 | 305 | } |
306 | 306 | return true; |
307 | 307 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @throws RequiredDataException |
313 | 313 | */ |
314 | 314 | protected function verifyData(){ |
315 | - if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)) { |
|
315 | + if (isset($this->_DATA_TYPE) || !empty($this->_DATA_TYPE)){ |
|
316 | 316 | $this->verifyDataType(); |
317 | 317 | } |
318 | 318 | if (!empty($this->_REQUIRED_DATA)){ |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | * @throws RequiredDataException |
328 | 328 | */ |
329 | 329 | protected function verifyDataType(){ |
330 | - if (gettype($this->Data) !== $this->_DATA_TYPE) { |
|
331 | - throw new RequiredDataException(get_called_class(),"Valid DataType is {$this->_DATA_TYPE}"); |
|
330 | + if (gettype($this->Data)!==$this->_DATA_TYPE){ |
|
331 | + throw new RequiredDataException(get_called_class(), "Valid DataType is {$this->_DATA_TYPE}"); |
|
332 | 332 | } |
333 | 333 | return true; |
334 | 334 | } |
@@ -340,13 +340,13 @@ discard block |
||
340 | 340 | */ |
341 | 341 | protected function verifyRequiredData(){ |
342 | 342 | $errors = array(); |
343 | - foreach($this->_REQUIRED_DATA as $property => $defaultValue){ |
|
343 | + foreach ($this->_REQUIRED_DATA as $property => $defaultValue){ |
|
344 | 344 | if (!isset($this->Data[$property])){ |
345 | 345 | $errors[] = $property; |
346 | 346 | } |
347 | 347 | } |
348 | 348 | if (count($errors)>0){ |
349 | - throw new RequiredDataException(get_called_class(),"Missing data for ".implode(",",$errors)); |
|
349 | + throw new RequiredDataException(get_called_class(), "Missing data for ".implode(",", $errors)); |
|
350 | 350 | } |
351 | 351 | return true; |
352 | 352 | } |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * @return bool |
357 | 357 | */ |
358 | 358 | protected function requiresOptions(){ |
359 | - return strpos($this->_URL,"$") === FALSE?FALSE:TRUE; |
|
359 | + return strpos($this->_URL, "$")===FALSE?FALSE:TRUE; |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | } |
363 | 363 | \ No newline at end of file |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | public function __construct($baseUrl,array $options = array()){ |
100 | 100 | $this->baseUrl = $baseUrl; |
101 | 101 | |
102 | - if (!empty($options)) { |
|
102 | + if (!empty($options)){ |
|
103 | 103 | $this->setOptions($options); |
104 | 104 | } |
105 | 105 | $this->configureURL(); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | /** |
127 | 127 | * @inheritdoc |
128 | 128 | */ |
129 | - public function setAuth($accessToken) { |
|
129 | + public function setAuth($accessToken){ |
|
130 | 130 | $this->accessToken = $accessToken; |
131 | 131 | return $this; |
132 | 132 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | /** |
135 | 135 | * @inheritdoc |
136 | 136 | */ |
137 | - public function setUrl($url) { |
|
137 | + public function setUrl($url){ |
|
138 | 138 | $this->Url = $url; |
139 | 139 | return $this; |
140 | 140 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | /** |
143 | 143 | * @inheritdoc |
144 | 144 | */ |
145 | - public function setRequest(RequestInterface $Request) { |
|
145 | + public function setRequest(RequestInterface $Request){ |
|
146 | 146 | $this->Request = $Request; |
147 | 147 | return $this; |
148 | 148 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | /** |
151 | 151 | * @inheritdoc |
152 | 152 | */ |
153 | - public function setResponse(ResponseInterface $Response) { |
|
153 | + public function setResponse(ResponseInterface $Response){ |
|
154 | 154 | $this->Response = $Response; |
155 | 155 | return $this; |
156 | 156 | } |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | public function execute($data = NULL){ |
201 | 201 | $data = ($data === NULL?$this->Data:$data); |
202 | 202 | $this->configureData($data); |
203 | - if (is_object($this->Request)) { |
|
203 | + if (is_object($this->Request)){ |
|
204 | 204 | $this->configureRequest(); |
205 | 205 | $this->Request->send(); |
206 | 206 | $this->configureResponse(); |
207 | - }else{ |
|
207 | + } else{ |
|
208 | 208 | throw new InvalidRequestException(get_called_class(),"Request property not configured"); |
209 | 209 | } |
210 | 210 | return $this; |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | /** |
214 | 214 | * @inheritdoc |
215 | 215 | */ |
216 | - public function authRequired() { |
|
216 | + public function authRequired(){ |
|
217 | 217 | return $this->_AUTH_REQUIRED; |
218 | 218 | } |
219 | 219 | |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | * @throws RequiredDataException |
224 | 224 | */ |
225 | 225 | protected function configureRequest(){ |
226 | - if ($this->verifyUrl()) { |
|
226 | + if ($this->verifyUrl()){ |
|
227 | 227 | $this->Request->setURL($this->Url); |
228 | 228 | } |
229 | - if ($this->verifyData() && !empty($this->Data)) { |
|
229 | + if ($this->verifyData() && !empty($this->Data)){ |
|
230 | 230 | $this->Request->setBody($this->Data); |
231 | 231 | } |
232 | 232 | $this->configureAuth(); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * Configures the authentication header on the Request object |
248 | 248 | */ |
249 | 249 | protected function configureAuth(){ |
250 | - if ($this->authRequired()) { |
|
250 | + if ($this->authRequired()){ |
|
251 | 251 | $this->Request->addHeader('OAuth-Token', $this->accessToken); |
252 | 252 | } |
253 | 253 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | */ |
285 | 285 | protected function configureURL(){ |
286 | 286 | $url = $this->_URL; |
287 | - if ($this->requiresOptions()) { |
|
287 | + if ($this->requiresOptions()){ |
|
288 | 288 | foreach($this->Options as $key => $option){ |
289 | 289 | $url = preg_replace('/(\$.*?[^\/]*)/',$option,$url,1); |
290 | 290 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @throws RequiredDataException |
313 | 313 | */ |
314 | 314 | protected function verifyData(){ |
315 | - if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)) { |
|
315 | + if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)){ |
|
316 | 316 | $this->verifyDataType(); |
317 | 317 | } |
318 | 318 | if (!empty($this->_REQUIRED_DATA)){ |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * @throws RequiredDataException |
328 | 328 | */ |
329 | 329 | protected function verifyDataType(){ |
330 | - if (gettype($this->Data) !== $this->_DATA_TYPE) { |
|
330 | + if (gettype($this->Data) !== $this->_DATA_TYPE){ |
|
331 | 331 | throw new RequiredDataException(get_called_class(),"Valid DataType is {$this->_DATA_TYPE}"); |
332 | 332 | } |
333 | 333 | return true; |
@@ -32,19 +32,19 @@ |
||
32 | 32 | * @throws RequiredOptionsException |
33 | 33 | */ |
34 | 34 | protected function configureData($data){ |
35 | - if (is_string($data)) { |
|
36 | - if (!empty($this->Options)) { |
|
35 | + if (is_string($data)){ |
|
36 | + if (!empty($this->Options)){ |
|
37 | 37 | $fileField = end($this->Options); |
38 | 38 | $data = array( |
39 | 39 | $fileField => $data |
40 | 40 | ); |
41 | - } else { |
|
41 | + }else{ |
|
42 | 42 | throw new RequiredOptionsException(get_called_class(), "Options are required, when passing String for data."); |
43 | 43 | } |
44 | 44 | } |
45 | 45 | if (is_array($data)){ |
46 | 46 | foreach ($data as $key => $value){ |
47 | - if (!array_key_exists($key,$this->_REQUIRED_DATA)){ |
|
47 | + if (!array_key_exists($key, $this->_REQUIRED_DATA)){ |
|
48 | 48 | $data[$key] = $this->setFileFieldValue($value); |
49 | 49 | } |
50 | 50 | } |
@@ -32,13 +32,13 @@ |
||
32 | 32 | * @throws RequiredOptionsException |
33 | 33 | */ |
34 | 34 | protected function configureData($data){ |
35 | - if (is_string($data)) { |
|
36 | - if (!empty($this->Options)) { |
|
35 | + if (is_string($data)){ |
|
36 | + if (!empty($this->Options)){ |
|
37 | 37 | $fileField = end($this->Options); |
38 | 38 | $data = array( |
39 | 39 | $fileField => $data |
40 | 40 | ); |
41 | - } else { |
|
41 | + } else{ |
|
42 | 42 | throw new RequiredOptionsException(get_called_class(), "Options are required, when passing String for data."); |
43 | 43 | } |
44 | 44 | } |
@@ -30,23 +30,23 @@ |
||
30 | 30 | 'method' => '' |
31 | 31 | ); |
32 | 32 | |
33 | - protected function configureData($data) { |
|
34 | - if (!isset($data['requests'])) { |
|
33 | + protected function configureData($data){ |
|
34 | + if (!isset($data['requests'])){ |
|
35 | 35 | $requestData = array( |
36 | 36 | 'requests' => array() |
37 | 37 | ); |
38 | 38 | $counter = 0; |
39 | - foreach ($data as $key => $EntryPoint) { |
|
40 | - if (is_object($EntryPoint)) { |
|
39 | + foreach ($data as $key => $EntryPoint){ |
|
40 | + if (is_object($EntryPoint)){ |
|
41 | 41 | $requestData['requests'][$counter] = $this->bulkRequest; |
42 | 42 | $requestData['requests'][$counter]['method'] = $EntryPoint->getRequest()->getType(); |
43 | - if ($requestData['requests'][$counter]['method'] == "POST" || $requestData['requests'][$counter]['method'] == "PUT") { |
|
43 | + if ($requestData['requests'][$counter]['method']=="POST" || $requestData['requests'][$counter]['method']=="PUT"){ |
|
44 | 44 | $requestData['requests'][$counter]['data'] = json_encode($EntryPoint->getData()); |
45 | - } else { |
|
45 | + }else{ |
|
46 | 46 | unset($requestData['requests'][$counter]['data']); |
47 | 47 | } |
48 | 48 | $requestData['requests'][$counter]['headers'] = $EntryPoint->getRequest()->getHeaders(); |
49 | - $requestData['requests'][$counter]['url'] = "v10/" . str_replace($this->baseUrl, "", $EntryPoint->getUrl()); |
|
49 | + $requestData['requests'][$counter]['url'] = "v10/".str_replace($this->baseUrl, "", $EntryPoint->getUrl()); |
|
50 | 50 | |
51 | 51 | $counter++; |
52 | 52 | } |
@@ -30,19 +30,19 @@ |
||
30 | 30 | 'method' => '' |
31 | 31 | ); |
32 | 32 | |
33 | - protected function configureData($data) { |
|
34 | - if (!isset($data['requests'])) { |
|
33 | + protected function configureData($data){ |
|
34 | + if (!isset($data['requests'])){ |
|
35 | 35 | $requestData = array( |
36 | 36 | 'requests' => array() |
37 | 37 | ); |
38 | 38 | $counter = 0; |
39 | - foreach ($data as $key => $EntryPoint) { |
|
40 | - if (is_object($EntryPoint)) { |
|
39 | + foreach ($data as $key => $EntryPoint){ |
|
40 | + if (is_object($EntryPoint)){ |
|
41 | 41 | $requestData['requests'][$counter] = $this->bulkRequest; |
42 | 42 | $requestData['requests'][$counter]['method'] = $EntryPoint->getRequest()->getType(); |
43 | - if ($requestData['requests'][$counter]['method'] == "POST" || $requestData['requests'][$counter]['method'] == "PUT") { |
|
43 | + if ($requestData['requests'][$counter]['method'] == "POST" || $requestData['requests'][$counter]['method'] == "PUT"){ |
|
44 | 44 | $requestData['requests'][$counter]['data'] = json_encode($EntryPoint->getData()); |
45 | - } else { |
|
45 | + } else{ |
|
46 | 46 | unset($requestData['requests'][$counter]['data']); |
47 | 47 | } |
48 | 48 | $requestData['requests'][$counter]['headers'] = $EntryPoint->getRequest()->getHeaders(); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | protected $destinationPath; |
23 | 23 | |
24 | 24 | public function __construct($curlRequest, $curlResponse = NULL, $destination = NULL){ |
25 | - parent::__construct($curlRequest,$curlResponse); |
|
25 | + parent::__construct($curlRequest, $curlResponse); |
|
26 | 26 | $this->setDestinationPath($destination); |
27 | 27 | } |
28 | 28 | |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | * Extract Filename from Headers |
32 | 32 | * @param mixed $curlResponse |
33 | 33 | */ |
34 | - public function setCurlResponse($curlResponse) { |
|
34 | + public function setCurlResponse($curlResponse){ |
|
35 | 35 | parent::setCurlResponse($curlResponse); |
36 | - if (!$this->error) { |
|
37 | - if (empty($this->fileName)) { |
|
36 | + if (!$this->error){ |
|
37 | + if (empty($this->fileName)){ |
|
38 | 38 | $this->extractFileName(); |
39 | 39 | } |
40 | 40 | $this->writeFile(); |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | mkdir($this->destinationPath, 0777); |
96 | 96 | } |
97 | 97 | $file = $this->file(); |
98 | - $fileHandle = fopen($file,'w+'); |
|
99 | - fwrite($fileHandle,$this->body); |
|
98 | + $fileHandle = fopen($file, 'w+'); |
|
99 | + fwrite($fileHandle, $this->body); |
|
100 | 100 | fclose($fileHandle); |
101 | 101 | return $file; |
102 | 102 | }else{ |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | * Extract Filename from Headers |
32 | 32 | * @param mixed $curlResponse |
33 | 33 | */ |
34 | - public function setCurlResponse($curlResponse) { |
|
34 | + public function setCurlResponse($curlResponse){ |
|
35 | 35 | parent::setCurlResponse($curlResponse); |
36 | - if (!$this->error) { |
|
37 | - if (empty($this->fileName)) { |
|
36 | + if (!$this->error){ |
|
37 | + if (empty($this->fileName)){ |
|
38 | 38 | $this->extractFileName(); |
39 | 39 | } |
40 | 40 | $this->writeFile(); |
@@ -59,8 +59,7 @@ discard block |
||
59 | 59 | * Extract the filename from the Headers, and store it in filename property |
60 | 60 | */ |
61 | 61 | protected function extractFileName(){ |
62 | - foreach (explode("\r\n", $this->headers) as $header) |
|
63 | - { |
|
62 | + foreach (explode("\r\n", $this->headers) as $header){ |
|
64 | 63 | if (strpos($header, 'filename')!==FALSE){ |
65 | 64 | $this->setFileName(substr($header, (strpos($header, "\"")+1), -1)); |
66 | 65 | } |
@@ -99,7 +98,7 @@ discard block |
||
99 | 98 | fwrite($fileHandle,$this->body); |
100 | 99 | fclose($fileHandle); |
101 | 100 | return $file; |
102 | - }else{ |
|
101 | + } else{ |
|
103 | 102 | return FALSE; |
104 | 103 | } |
105 | 104 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | * The directory in which to download the File |
13 | 13 | * @var string |
14 | 14 | */ |
15 | - protected $downloadDir = null; |
|
15 | + protected $downloadDir = NULL; |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * @inheritdoc |