@@ -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; |
@@ -22,17 +22,17 @@ |
||
22 | 22 | echo "<h3>Requests Completed</h3><pre>"; |
23 | 23 | print_r($response->getBody()); |
24 | 24 | echo "</pre>"; |
25 | - }else{ |
|
25 | + } else{ |
|
26 | 26 | echo "<h3>Request Failed</h3><pre>"; |
27 | 27 | print_r($response); |
28 | 28 | echo "</pre>"; |
29 | 29 | } |
30 | 30 | |
31 | -}catch (\SugarAPI\SDK\Exception\Authentication\AuthenticationException $ex){ |
|
31 | +} catch (\SugarAPI\SDK\Exception\Authentication\AuthenticationException $ex){ |
|
32 | 32 | echo "Credentials:<pre>"; |
33 | 33 | print_r($SugarAPI->getCredentials()); |
34 | 34 | echo "</pre> Error Message: "; |
35 | 35 | print $ex->getMessage(); |
36 | -}catch (\SugarAPI\SDK\Exception\SDKException $ex){ |
|
36 | +} catch (\SugarAPI\SDK\Exception\SDKException $ex){ |
|
37 | 37 | echo $ex->__toString(); |
38 | 38 | } |
39 | 39 | \ No newline at end of file |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | |
4 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
4 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
5 | 5 | |
6 | 6 | try{ |
7 | - $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7700/',array('username' => 'admin','password'=>'asdf')); |
|
7 | + $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7700/', array('username' => 'admin', 'password'=>'asdf')); |
|
8 | 8 | $SugarAPI->login(); |
9 | 9 | |
10 | 10 | $Accounts = $SugarAPI->filterRecords('Accounts')->setData(array('max_num'=> 5)); |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | require_once __DIR__.'/../vendor/autoload.php'; |
4 | 4 | |
5 | -try { |
|
5 | +try{ |
|
6 | 6 | $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7621/', array( |
7 | 7 | 'username' => 'admin', |
8 | 8 | 'password' => 'asdf' |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | 'username' => 'admin', |
19 | 19 | 'password' => 'asdf' |
20 | 20 | )); |
21 | - if ($SugarAPI2->authenticated()) { |
|
21 | + if ($SugarAPI2->authenticated()){ |
|
22 | 22 | echo "Authenticated!"; |
23 | 23 | print_r($SugarAPI2->getToken()); |
24 | 24 | } |
25 | -} catch(\SugarAPI\SDK\Exception\SDKException $ex){ |
|
25 | +}catch (\SugarAPI\SDK\Exception\SDKException $ex){ |
|
26 | 26 | print_r($ex->getMessage()); |
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | require_once __DIR__.'/../vendor/autoload.php'; |
4 | 4 | |
5 | -try { |
|
5 | +try{ |
|
6 | 6 | $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7621/', array( |
7 | 7 | 'username' => 'admin', |
8 | 8 | 'password' => 'asdf' |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | 'username' => 'admin', |
19 | 19 | 'password' => 'asdf' |
20 | 20 | )); |
21 | - if ($SugarAPI2->authenticated()) { |
|
21 | + if ($SugarAPI2->authenticated()){ |
|
22 | 22 | echo "Authenticated!"; |
23 | 23 | print_r($SugarAPI2->getToken()); |
24 | 24 | } |
@@ -8,14 +8,14 @@ |
||
8 | 8 | |
9 | 9 | abstract class AbstractPostFileEntryPoint extends AbstractEntryPoint { |
10 | 10 | |
11 | - public function __construct($url, array $options = array()) { |
|
11 | + public function __construct($url, array $options = array()){ |
|
12 | 12 | $this->setRequest(new POSTFile()); |
13 | 13 | parent::__construct($url, $options); |
14 | 14 | } |
15 | 15 | |
16 | - public function execute($data = null) { |
|
16 | + public function execute($data = null){ |
|
17 | 17 | parent::execute($data); |
18 | - $this->setResponse(new JSON($this->Request->getResponse(),$this->Request->getCurlObject())); |
|
18 | + $this->setResponse(new JSON($this->Request->getResponse(), $this->Request->getCurlObject())); |
|
19 | 19 | return $this; |
20 | 20 | } |
21 | 21 |
@@ -8,12 +8,12 @@ |
||
8 | 8 | |
9 | 9 | abstract class AbstractPostFileEntryPoint extends AbstractEntryPoint { |
10 | 10 | |
11 | - public function __construct($url, array $options = array()) { |
|
11 | + public function __construct($url, array $options = array()){ |
|
12 | 12 | $this->setRequest(new POSTFile()); |
13 | 13 | parent::__construct($url, $options); |
14 | 14 | } |
15 | 15 | |
16 | - public function execute($data = null) { |
|
16 | + public function execute($data = null){ |
|
17 | 17 | parent::execute($data); |
18 | 18 | $this->setResponse(new JSON($this->Request->getResponse(),$this->Request->getCurlObject())); |
19 | 19 | return $this; |
@@ -13,7 +13,7 @@ |
||
13 | 13 | parent::__construct($url, $options); |
14 | 14 | } |
15 | 15 | |
16 | - public function execute($data = null) { |
|
16 | + public function execute($data = NULL) { |
|
17 | 17 | parent::execute($data); |
18 | 18 | $this->setResponse(new JSON($this->Request->getResponse(),$this->Request->getCurlObject())); |
19 | 19 | return $this; |
@@ -8,14 +8,14 @@ |
||
8 | 8 | |
9 | 9 | abstract class AbstractPostFileEntryPoint extends AbstractEntryPoint { |
10 | 10 | |
11 | - public function __construct($url, array $options = array()) { |
|
11 | + public function __construct($url, array $options = array()){ |
|
12 | 12 | $this->setRequest(new POSTFile()); |
13 | 13 | parent::__construct($url, $options); |
14 | 14 | } |
15 | 15 | |
16 | - public function execute($data = null) { |
|
16 | + public function execute($data = null){ |
|
17 | 17 | parent::execute($data); |
18 | - $this->setResponse(new JSON($this->Request->getResponse(),$this->Request->getCurlObject())); |
|
18 | + $this->setResponse(new JSON($this->Request->getResponse(), $this->Request->getCurlObject())); |
|
19 | 19 | return $this; |
20 | 20 | } |
21 | 21 |
@@ -8,12 +8,12 @@ |
||
8 | 8 | |
9 | 9 | abstract class AbstractPostFileEntryPoint extends AbstractEntryPoint { |
10 | 10 | |
11 | - public function __construct($url, array $options = array()) { |
|
11 | + public function __construct($url, array $options = array()){ |
|
12 | 12 | $this->setRequest(new POSTFile()); |
13 | 13 | parent::__construct($url, $options); |
14 | 14 | } |
15 | 15 | |
16 | - public function execute($data = null) { |
|
16 | + public function execute($data = null){ |
|
17 | 17 | parent::execute($data); |
18 | 18 | $this->setResponse(new JSON($this->Request->getResponse(),$this->Request->getCurlObject())); |
19 | 19 | return $this; |
@@ -13,7 +13,7 @@ |
||
13 | 13 | parent::__construct($url, $options); |
14 | 14 | } |
15 | 15 | |
16 | - public function execute($data = null) { |
|
16 | + public function execute($data = NULL) { |
|
17 | 17 | parent::execute($data); |
18 | 18 | $this->setResponse(new JSON($this->Request->getResponse(),$this->Request->getCurlObject())); |
19 | 19 | return $this; |
@@ -8,14 +8,14 @@ |
||
8 | 8 | |
9 | 9 | abstract class AbstractPostFileEntryPoint extends AbstractEntryPoint { |
10 | 10 | |
11 | - public function __construct($url, array $options = array()) { |
|
11 | + public function __construct($url, array $options = array()){ |
|
12 | 12 | $this->setRequest(new POSTFile()); |
13 | 13 | parent::__construct($url, $options); |
14 | 14 | } |
15 | 15 | |
16 | - public function execute($data = null) { |
|
16 | + public function execute($data = null){ |
|
17 | 17 | parent::execute($data); |
18 | - $this->setResponse(new JSON($this->Request->getResponse(),$this->Request->getCurlObject())); |
|
18 | + $this->setResponse(new JSON($this->Request->getResponse(), $this->Request->getCurlObject())); |
|
19 | 19 | return $this; |
20 | 20 | } |
21 | 21 |
@@ -8,12 +8,12 @@ |
||
8 | 8 | |
9 | 9 | abstract class AbstractPostFileEntryPoint extends AbstractEntryPoint { |
10 | 10 | |
11 | - public function __construct($url, array $options = array()) { |
|
11 | + public function __construct($url, array $options = array()){ |
|
12 | 12 | $this->setRequest(new POSTFile()); |
13 | 13 | parent::__construct($url, $options); |
14 | 14 | } |
15 | 15 | |
16 | - public function execute($data = null) { |
|
16 | + public function execute($data = null){ |
|
17 | 17 | parent::execute($data); |
18 | 18 | $this->setResponse(new JSON($this->Request->getResponse(),$this->Request->getCurlObject())); |
19 | 19 | return $this; |
@@ -13,7 +13,7 @@ |
||
13 | 13 | parent::__construct($url, $options); |
14 | 14 | } |
15 | 15 | |
16 | - public function execute($data = null) { |
|
16 | + public function execute($data = NULL) { |
|
17 | 17 | parent::execute($data); |
18 | 18 | $this->setResponse(new JSON($this->Request->getResponse(),$this->Request->getCurlObject())); |
19 | 19 | return $this; |
@@ -8,14 +8,14 @@ |
||
8 | 8 | |
9 | 9 | abstract class AbstractPostFileEntryPoint extends AbstractEntryPoint { |
10 | 10 | |
11 | - public function __construct($url, array $options = array()) { |
|
11 | + public function __construct($url, array $options = array()){ |
|
12 | 12 | $this->setRequest(new POSTFile()); |
13 | 13 | parent::__construct($url, $options); |
14 | 14 | } |
15 | 15 | |
16 | - public function execute($data = null) { |
|
16 | + public function execute($data = null){ |
|
17 | 17 | parent::execute($data); |
18 | - $this->setResponse(new JSON($this->Request->getResponse(),$this->Request->getCurlObject())); |
|
18 | + $this->setResponse(new JSON($this->Request->getResponse(), $this->Request->getCurlObject())); |
|
19 | 19 | return $this; |
20 | 20 | } |
21 | 21 |
@@ -8,12 +8,12 @@ |
||
8 | 8 | |
9 | 9 | abstract class AbstractPostFileEntryPoint extends AbstractEntryPoint { |
10 | 10 | |
11 | - public function __construct($url, array $options = array()) { |
|
11 | + public function __construct($url, array $options = array()){ |
|
12 | 12 | $this->setRequest(new POSTFile()); |
13 | 13 | parent::__construct($url, $options); |
14 | 14 | } |
15 | 15 | |
16 | - public function execute($data = null) { |
|
16 | + public function execute($data = null){ |
|
17 | 17 | parent::execute($data); |
18 | 18 | $this->setResponse(new JSON($this->Request->getResponse(),$this->Request->getCurlObject())); |
19 | 19 | return $this; |
@@ -13,7 +13,7 @@ |
||
13 | 13 | parent::__construct($url, $options); |
14 | 14 | } |
15 | 15 | |
16 | - public function execute($data = null) { |
|
16 | + public function execute($data = NULL) { |
|
17 | 17 | parent::execute($data); |
18 | 18 | $this->setResponse(new JSON($this->Request->getResponse(),$this->Request->getCurlObject())); |
19 | 19 | return $this; |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | protected $accessToken; |
117 | 117 | |
118 | 118 | |
119 | - public function __construct($baseUrl,array $options = array()){ |
|
119 | + public function __construct($baseUrl, array $options = array()){ |
|
120 | 120 | $this->baseUrl = $baseUrl; |
121 | 121 | |
122 | - if (!empty($options)) { |
|
122 | + if (!empty($options)){ |
|
123 | 123 | $this->setOptions($options); |
124 | - }elseif(!$this->requiresOptions()){ |
|
124 | + }elseif (!$this->requiresOptions()){ |
|
125 | 125 | $this->configureURL(); |
126 | 126 | } |
127 | 127 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | /** |
148 | 148 | * @inheritdoc |
149 | 149 | */ |
150 | - public function setAuth($accessToken) { |
|
150 | + public function setAuth($accessToken){ |
|
151 | 151 | $this->accessToken = $accessToken; |
152 | 152 | return $this; |
153 | 153 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | /** |
156 | 156 | * @inheritdoc |
157 | 157 | */ |
158 | - public function setUrl($url) { |
|
158 | + public function setUrl($url){ |
|
159 | 159 | $this->Url = $url; |
160 | 160 | return $this; |
161 | 161 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | /** |
164 | 164 | * @inheritdoc |
165 | 165 | */ |
166 | - public function setRequest(RequestInterface $Request) { |
|
166 | + public function setRequest(RequestInterface $Request){ |
|
167 | 167 | $this->Request = $Request; |
168 | 168 | return $this; |
169 | 169 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | /** |
172 | 172 | * @inheritdoc |
173 | 173 | */ |
174 | - public function setResponse(ResponseInterface $Response) { |
|
174 | + public function setResponse(ResponseInterface $Response){ |
|
175 | 175 | $this->Response = $Response; |
176 | 176 | return $this; |
177 | 177 | } |
@@ -219,13 +219,13 @@ discard block |
||
219 | 219 | * @throws InvalidURLException |
220 | 220 | */ |
221 | 221 | public function execute($data = NULL){ |
222 | - $data = ($data === NULL?$this->Data:$data); |
|
222 | + $data = ($data===NULL?$this->Data:$data); |
|
223 | 223 | $this->configureData($data); |
224 | - if ($this->verifyOptions() && is_object($this->Request)) { |
|
224 | + if ($this->verifyOptions() && is_object($this->Request)){ |
|
225 | 225 | $this->configureRequest(); |
226 | 226 | $this->Request->send(); |
227 | 227 | }else{ |
228 | - throw new InvalidRequestException(get_called_class(),"Request property not configured"); |
|
228 | + throw new InvalidRequestException(get_called_class(), "Request property not configured"); |
|
229 | 229 | } |
230 | 230 | return $this; |
231 | 231 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | /** |
234 | 234 | * @inheritdoc |
235 | 235 | */ |
236 | - public function authRequired() { |
|
236 | + public function authRequired(){ |
|
237 | 237 | return $this->_AUTH_REQUIRED; |
238 | 238 | } |
239 | 239 | |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | * @throws RequiredDataException |
244 | 244 | */ |
245 | 245 | protected function configureRequest(){ |
246 | - if ($this->verifyUrl()) { |
|
246 | + if ($this->verifyUrl()){ |
|
247 | 247 | $this->Request->setURL($this->Url); |
248 | 248 | } |
249 | - if ($this->verifyData() && !empty($this->Data)) { |
|
249 | + if ($this->verifyData() && !empty($this->Data)){ |
|
250 | 250 | $this->Request->setBody($this->Data); |
251 | 251 | } |
252 | 252 | $this->configureAuth(); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * Configures the authentication header on the Request object |
257 | 257 | */ |
258 | 258 | protected function configureAuth(){ |
259 | - if ($this->authRequired()) { |
|
259 | + if ($this->authRequired()){ |
|
260 | 260 | $this->Request->addHeader('OAuth-Token', $this->accessToken); |
261 | 261 | } |
262 | 262 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * @var $data |
267 | 267 | */ |
268 | 268 | protected function configureData($data){ |
269 | - if (!empty($this->_REQUIRED_DATA)&&is_array($data)){ |
|
269 | + if (!empty($this->_REQUIRED_DATA) && is_array($data)){ |
|
270 | 270 | $data = $this->configureDefaultData($data); |
271 | 271 | } |
272 | 272 | $this->setData($data); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @return array |
279 | 279 | */ |
280 | 280 | protected function configureDefaultData(array $data){ |
281 | - foreach($this->_REQUIRED_DATA as $property => $value){ |
|
281 | + foreach ($this->_REQUIRED_DATA as $property => $value){ |
|
282 | 282 | if (!isset($data[$property]) && $value!==NULL){ |
283 | 283 | $data[$property] = $value; |
284 | 284 | } |
@@ -293,18 +293,18 @@ discard block |
||
293 | 293 | */ |
294 | 294 | protected function configureURL(){ |
295 | 295 | $url = $this->_URL; |
296 | - if ($this->requiresOptions()) { |
|
296 | + if ($this->requiresOptions()){ |
|
297 | 297 | $urlParts = explode("/", $this->_URL); |
298 | 298 | $o = 0; |
299 | - foreach ($urlParts as $key => $part) { |
|
300 | - if (strpos($part, "$") !== FALSE) { |
|
301 | - if (isset($this->Options[$o])) { |
|
299 | + foreach ($urlParts as $key => $part){ |
|
300 | + if (strpos($part, "$")!==FALSE){ |
|
301 | + if (isset($this->Options[$o])){ |
|
302 | 302 | $urlParts[$key] = $this->Options[$o]; |
303 | 303 | $o++; |
304 | 304 | } |
305 | 305 | } |
306 | 306 | } |
307 | - $url = implode($urlParts,"/"); |
|
307 | + $url = implode($urlParts, "/"); |
|
308 | 308 | } |
309 | 309 | $url = $this->baseUrl.$url; |
310 | 310 | $this->setUrl($url); |
@@ -316,9 +316,9 @@ discard block |
||
316 | 316 | * @throws InvalidURLException |
317 | 317 | */ |
318 | 318 | protected function verifyUrl(){ |
319 | - $UrlArray = explode("?",$this->Url); |
|
320 | - if (strpos($UrlArray[0],"$") !== FALSE){ |
|
321 | - throw new InvalidURLException(get_called_class(),"Configured URL is ".$this->Url); |
|
319 | + $UrlArray = explode("?", $this->Url); |
|
320 | + if (strpos($UrlArray[0], "$")!==FALSE){ |
|
321 | + throw new InvalidURLException(get_called_class(), "Configured URL is ".$this->Url); |
|
322 | 322 | } |
323 | 323 | return true; |
324 | 324 | } |
@@ -329,11 +329,11 @@ discard block |
||
329 | 329 | * @throws RequiredOptionsException |
330 | 330 | */ |
331 | 331 | protected function verifyOptions(){ |
332 | - $urlVarCount = substr_count($this->_URL,"$"); |
|
332 | + $urlVarCount = substr_count($this->_URL, "$"); |
|
333 | 333 | $optionCount = 0; |
334 | 334 | $optionCount += count($this->Options); |
335 | 335 | if ($urlVarCount>$optionCount){ |
336 | - throw new RequiredOptionsException(get_called_class(),"URL requires $urlVarCount options, only $optionCount provided."); |
|
336 | + throw new RequiredOptionsException(get_called_class(), "URL requires $urlVarCount options, only $optionCount provided."); |
|
337 | 337 | } |
338 | 338 | return true; |
339 | 339 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @throws RequiredDataException |
345 | 345 | */ |
346 | 346 | protected function verifyData(){ |
347 | - if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)) { |
|
347 | + if (isset($this->_DATA_TYPE) || !empty($this->_DATA_TYPE)){ |
|
348 | 348 | $this->verifyDataType(); |
349 | 349 | } |
350 | 350 | if (!empty($this->_REQUIRED_DATA)){ |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | * @throws RequiredDataException |
360 | 360 | */ |
361 | 361 | protected function verifyDataType(){ |
362 | - if (gettype($this->Data) !== $this->_DATA_TYPE) { |
|
363 | - throw new RequiredDataException(get_called_class(),"Valid DataType is {$this->_DATA_TYPE}"); |
|
362 | + if (gettype($this->Data)!==$this->_DATA_TYPE){ |
|
363 | + throw new RequiredDataException(get_called_class(), "Valid DataType is {$this->_DATA_TYPE}"); |
|
364 | 364 | } |
365 | 365 | return true; |
366 | 366 | } |
@@ -372,13 +372,13 @@ discard block |
||
372 | 372 | */ |
373 | 373 | protected function verifyRequiredData(){ |
374 | 374 | $errors = array(); |
375 | - foreach($this->_REQUIRED_DATA as $property => $defaultValue){ |
|
375 | + foreach ($this->_REQUIRED_DATA as $property => $defaultValue){ |
|
376 | 376 | if (!isset($this->Data[$property])){ |
377 | 377 | $errors[] = $property; |
378 | 378 | } |
379 | 379 | } |
380 | 380 | if (count($errors)>0){ |
381 | - throw new RequiredDataException(get_called_class(),"Missing data for ".implode(",",$errors)); |
|
381 | + throw new RequiredDataException(get_called_class(), "Missing data for ".implode(",", $errors)); |
|
382 | 382 | } |
383 | 383 | return true; |
384 | 384 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * @return bool |
389 | 389 | */ |
390 | 390 | protected function requiresOptions(){ |
391 | - return strpos($this->_URL,"$") === FALSE?FALSE:TRUE; |
|
391 | + return strpos($this->_URL, "$")===FALSE?FALSE:TRUE; |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | } |
395 | 395 | \ No newline at end of file |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | public function __construct($baseUrl,array $options = array()){ |
120 | 120 | $this->baseUrl = $baseUrl; |
121 | 121 | |
122 | - if (!empty($options)) { |
|
122 | + if (!empty($options)){ |
|
123 | 123 | $this->setOptions($options); |
124 | - }elseif(!$this->requiresOptions()){ |
|
124 | + } elseif(!$this->requiresOptions()){ |
|
125 | 125 | $this->configureURL(); |
126 | 126 | } |
127 | 127 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | /** |
148 | 148 | * @inheritdoc |
149 | 149 | */ |
150 | - public function setAuth($accessToken) { |
|
150 | + public function setAuth($accessToken){ |
|
151 | 151 | $this->accessToken = $accessToken; |
152 | 152 | return $this; |
153 | 153 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | /** |
156 | 156 | * @inheritdoc |
157 | 157 | */ |
158 | - public function setUrl($url) { |
|
158 | + public function setUrl($url){ |
|
159 | 159 | $this->Url = $url; |
160 | 160 | return $this; |
161 | 161 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | /** |
164 | 164 | * @inheritdoc |
165 | 165 | */ |
166 | - public function setRequest(RequestInterface $Request) { |
|
166 | + public function setRequest(RequestInterface $Request){ |
|
167 | 167 | $this->Request = $Request; |
168 | 168 | return $this; |
169 | 169 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | /** |
172 | 172 | * @inheritdoc |
173 | 173 | */ |
174 | - public function setResponse(ResponseInterface $Response) { |
|
174 | + public function setResponse(ResponseInterface $Response){ |
|
175 | 175 | $this->Response = $Response; |
176 | 176 | return $this; |
177 | 177 | } |
@@ -221,10 +221,10 @@ discard block |
||
221 | 221 | public function execute($data = NULL){ |
222 | 222 | $data = ($data === NULL?$this->Data:$data); |
223 | 223 | $this->configureData($data); |
224 | - if ($this->verifyOptions() && is_object($this->Request)) { |
|
224 | + if ($this->verifyOptions() && is_object($this->Request)){ |
|
225 | 225 | $this->configureRequest(); |
226 | 226 | $this->Request->send(); |
227 | - }else{ |
|
227 | + } else{ |
|
228 | 228 | throw new InvalidRequestException(get_called_class(),"Request property not configured"); |
229 | 229 | } |
230 | 230 | return $this; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | /** |
234 | 234 | * @inheritdoc |
235 | 235 | */ |
236 | - public function authRequired() { |
|
236 | + public function authRequired(){ |
|
237 | 237 | return $this->_AUTH_REQUIRED; |
238 | 238 | } |
239 | 239 | |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | * @throws RequiredDataException |
244 | 244 | */ |
245 | 245 | protected function configureRequest(){ |
246 | - if ($this->verifyUrl()) { |
|
246 | + if ($this->verifyUrl()){ |
|
247 | 247 | $this->Request->setURL($this->Url); |
248 | 248 | } |
249 | - if ($this->verifyData() && !empty($this->Data)) { |
|
249 | + if ($this->verifyData() && !empty($this->Data)){ |
|
250 | 250 | $this->Request->setBody($this->Data); |
251 | 251 | } |
252 | 252 | $this->configureAuth(); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * Configures the authentication header on the Request object |
257 | 257 | */ |
258 | 258 | protected function configureAuth(){ |
259 | - if ($this->authRequired()) { |
|
259 | + if ($this->authRequired()){ |
|
260 | 260 | $this->Request->addHeader('OAuth-Token', $this->accessToken); |
261 | 261 | } |
262 | 262 | } |
@@ -293,12 +293,12 @@ discard block |
||
293 | 293 | */ |
294 | 294 | protected function configureURL(){ |
295 | 295 | $url = $this->_URL; |
296 | - if ($this->requiresOptions()) { |
|
296 | + if ($this->requiresOptions()){ |
|
297 | 297 | $urlParts = explode("/", $this->_URL); |
298 | 298 | $o = 0; |
299 | - foreach ($urlParts as $key => $part) { |
|
300 | - if (strpos($part, "$") !== FALSE) { |
|
301 | - if (isset($this->Options[$o])) { |
|
299 | + foreach ($urlParts as $key => $part){ |
|
300 | + if (strpos($part, "$") !== FALSE){ |
|
301 | + if (isset($this->Options[$o])){ |
|
302 | 302 | $urlParts[$key] = $this->Options[$o]; |
303 | 303 | $o++; |
304 | 304 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @throws RequiredDataException |
345 | 345 | */ |
346 | 346 | protected function verifyData(){ |
347 | - if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)) { |
|
347 | + if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)){ |
|
348 | 348 | $this->verifyDataType(); |
349 | 349 | } |
350 | 350 | if (!empty($this->_REQUIRED_DATA)){ |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * @throws RequiredDataException |
360 | 360 | */ |
361 | 361 | protected function verifyDataType(){ |
362 | - if (gettype($this->Data) !== $this->_DATA_TYPE) { |
|
362 | + if (gettype($this->Data) !== $this->_DATA_TYPE){ |
|
363 | 363 | throw new RequiredDataException(get_called_class(),"Valid DataType is {$this->_DATA_TYPE}"); |
364 | 364 | } |
365 | 365 | return true; |
@@ -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 |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | if (strpos($UrlArray[0],"$") !== FALSE){ |
321 | 321 | throw new InvalidURLException(get_called_class(),"Configured URL is ".$this->Url); |
322 | 322 | } |
323 | - return true; |
|
323 | + return TRUE; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | if ($urlVarCount>$optionCount){ |
336 | 336 | throw new RequiredOptionsException(get_called_class(),"URL requires $urlVarCount options, only $optionCount provided."); |
337 | 337 | } |
338 | - return true; |
|
338 | + return TRUE; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | if (!empty($this->_REQUIRED_DATA)){ |
351 | 351 | $this->verifyRequiredData(); |
352 | 352 | } |
353 | - return true; |
|
353 | + return TRUE; |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | if (gettype($this->Data) !== $this->_DATA_TYPE) { |
363 | 363 | throw new RequiredDataException(get_called_class(),"Valid DataType is {$this->_DATA_TYPE}"); |
364 | 364 | } |
365 | - return true; |
|
365 | + return TRUE; |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | if (count($errors)>0){ |
381 | 381 | throw new RequiredDataException(get_called_class(),"Missing data for ".implode(",",$errors)); |
382 | 382 | } |
383 | - return true; |
|
383 | + return TRUE; |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |