@@ -72,6 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * @inheritdoc |
| 75 | + * @param string $server |
|
| 75 | 76 | */ |
| 76 | 77 | public function setServer($server) { |
| 77 | 78 | $this->server = $server; |
@@ -150,7 +151,7 @@ discard block |
||
| 150 | 151 | /** |
| 151 | 152 | * @param $funcName |
| 152 | 153 | * @param $className |
| 153 | - * @return bool |
|
| 154 | + * @return AbstractClient |
|
| 154 | 155 | * @throws EntryPointException |
| 155 | 156 | */ |
| 156 | 157 | public function registerEntryPoint($funcName, $className){ |
@@ -246,6 +247,7 @@ discard block |
||
| 246 | 247 | |
| 247 | 248 | /** |
| 248 | 249 | * @inheritdoc |
| 250 | + * @param \stdClass $token |
|
| 249 | 251 | */ |
| 250 | 252 | public static function storeToken($token, $client_id) { |
| 251 | 253 | static::$_STORED_TOKENS[$client_id] = $token; |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | protected $entryPoints = array(); |
| 62 | 62 | |
| 63 | - public function __construct($server = '',array $credentials = array()){ |
|
| 64 | - if (!empty($server)) { |
|
| 63 | + public function __construct($server = '', array $credentials = array()){ |
|
| 64 | + if (!empty($server)){ |
|
| 65 | 65 | $this->setServer($server); |
| 66 | 66 | } |
| 67 | 67 | if (!empty($credentials)){ |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | /** |
| 74 | 74 | * @inheritdoc |
| 75 | 75 | */ |
| 76 | - public function setServer($server) { |
|
| 76 | + public function setServer($server){ |
|
| 77 | 77 | $this->server = $server; |
| 78 | 78 | $this->apiURL = Helpers::configureAPIURL($this->server); |
| 79 | 79 | return $this; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | /** |
| 83 | 83 | * @inheritdoc |
| 84 | 84 | */ |
| 85 | - public function getAPIUrl() { |
|
| 85 | + public function getAPIUrl(){ |
|
| 86 | 86 | return $this->apiURL; |
| 87 | 87 | } |
| 88 | 88 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | /** |
| 126 | 126 | * @inheritdoc |
| 127 | 127 | */ |
| 128 | - public function getServer() { |
|
| 128 | + public function getServer(){ |
|
| 129 | 129 | return $this->server; |
| 130 | 130 | } |
| 131 | 131 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @inheritdoc |
| 134 | 134 | */ |
| 135 | 135 | public function authenticated(){ |
| 136 | - return time() < $this->expiration; |
|
| 136 | + return time()<$this->expiration; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -155,10 +155,10 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public function registerEntryPoint($funcName, $className){ |
| 157 | 157 | $implements = class_implements($className); |
| 158 | - if (is_array($implements) && in_array('SugarAPI\SDK\EntryPoint\Interfaces\EPInterface',$implements)){ |
|
| 158 | + if (is_array($implements) && in_array('SugarAPI\SDK\EntryPoint\Interfaces\EPInterface', $implements)){ |
|
| 159 | 159 | $this->entryPoints[$funcName] = $className; |
| 160 | 160 | }else{ |
| 161 | - throw new EntryPointException($className,'Class must extend SugarAPI\SDK\EntryPoint\Interfaces\EPInterface'); |
|
| 161 | + throw new EntryPointException($className, 'Class must extend SugarAPI\SDK\EntryPoint\Interfaces\EPInterface'); |
|
| 162 | 162 | } |
| 163 | 163 | return $this; |
| 164 | 164 | } |
@@ -176,13 +176,13 @@ discard block |
||
| 176 | 176 | $EntryPoint = new $Class($this->apiURL, $params); |
| 177 | 177 | |
| 178 | 178 | if ($EntryPoint->authRequired()){ |
| 179 | - if (isset($this->token) && $this->authenticated()) { |
|
| 179 | + if (isset($this->token) && $this->authenticated()){ |
|
| 180 | 180 | $EntryPoint->setAuth($this->getToken()->access_token); |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | return $EntryPoint; |
| 184 | 184 | }else{ |
| 185 | - throw new EntryPointException($name,'Unregistered EntryPoint'); |
|
| 185 | + throw new EntryPointException($name, 'Unregistered EntryPoint'); |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | |
@@ -190,13 +190,13 @@ discard block |
||
| 190 | 190 | * @inheritdoc |
| 191 | 191 | * @throws AuthenticationException - When Login request fails |
| 192 | 192 | */ |
| 193 | - public function login() { |
|
| 193 | + public function login(){ |
|
| 194 | 194 | $EP = new OAuth2Token($this->apiURL); |
| 195 | 195 | $response = $EP->execute($this->credentials)->getResponse(); |
| 196 | 196 | if ($response->getStatus()=='200'){ |
| 197 | 197 | $this->setToken($response->getBody(false)); |
| 198 | - static::storeToken($this->token,$this->credentials['client_id']); |
|
| 199 | - } else { |
|
| 198 | + static::storeToken($this->token, $this->credentials['client_id']); |
|
| 199 | + }else{ |
|
| 200 | 200 | $error = $response->getBody(); |
| 201 | 201 | throw new AuthenticationException("Login Response [".$error['error']."] ".$error['error_message']); |
| 202 | 202 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $response = $EP->execute($refreshOptions)->getResponse(); |
| 218 | 218 | if ($response->getStatus()=='200'){ |
| 219 | 219 | $this->setToken($response->getBody(false)); |
| 220 | - static::storeToken($this->token,$this->credentials['client_id']); |
|
| 220 | + static::storeToken($this->token, $this->credentials['client_id']); |
|
| 221 | 221 | }else{ |
| 222 | 222 | $error = $response->getBody(); |
| 223 | 223 | throw new AuthenticationException("Refresh Response [".$error['error']."] ".$error['error_message']); |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | /** |
| 248 | 248 | * @inheritdoc |
| 249 | 249 | */ |
| 250 | - public static function storeToken($token, $client_id) { |
|
| 250 | + public static function storeToken($token, $client_id){ |
|
| 251 | 251 | static::$_STORED_TOKENS[$client_id] = $token; |
| 252 | 252 | return true; |
| 253 | 253 | } |
@@ -255,14 +255,14 @@ discard block |
||
| 255 | 255 | /** |
| 256 | 256 | * @inheritdoc |
| 257 | 257 | */ |
| 258 | - public static function getStoredToken($client_id) { |
|
| 258 | + public static function getStoredToken($client_id){ |
|
| 259 | 259 | return static::$_STORED_TOKENS[$client_id]; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
| 263 | 263 | * @inheritdoc |
| 264 | 264 | */ |
| 265 | - public static function removeStoredToken($client_id) { |
|
| 265 | + public static function removeStoredToken($client_id){ |
|
| 266 | 266 | unset(static::$_STORED_TOKENS[$client_id]); |
| 267 | 267 | return true; |
| 268 | 268 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | protected $entryPoints = array(); |
| 62 | 62 | |
| 63 | 63 | public function __construct($server = '',array $credentials = array()){ |
| 64 | - if (!empty($server)) { |
|
| 64 | + if (!empty($server)){ |
|
| 65 | 65 | $this->setServer($server); |
| 66 | 66 | } |
| 67 | 67 | if (!empty($credentials)){ |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | /** |
| 74 | 74 | * @inheritdoc |
| 75 | 75 | */ |
| 76 | - public function setServer($server) { |
|
| 76 | + public function setServer($server){ |
|
| 77 | 77 | $this->server = $server; |
| 78 | 78 | $this->apiURL = Helpers::configureAPIURL($this->server); |
| 79 | 79 | return $this; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | /** |
| 83 | 83 | * @inheritdoc |
| 84 | 84 | */ |
| 85 | - public function getAPIUrl() { |
|
| 85 | + public function getAPIUrl(){ |
|
| 86 | 86 | return $this->apiURL; |
| 87 | 87 | } |
| 88 | 88 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | /** |
| 126 | 126 | * @inheritdoc |
| 127 | 127 | */ |
| 128 | - public function getServer() { |
|
| 128 | + public function getServer(){ |
|
| 129 | 129 | return $this->server; |
| 130 | 130 | } |
| 131 | 131 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | $implements = class_implements($className); |
| 158 | 158 | if (is_array($implements) && in_array('SugarAPI\SDK\EntryPoint\Interfaces\EPInterface',$implements)){ |
| 159 | 159 | $this->entryPoints[$funcName] = $className; |
| 160 | - }else{ |
|
| 160 | + } else{ |
|
| 161 | 161 | throw new EntryPointException($className,'Class must extend SugarAPI\SDK\EntryPoint\Interfaces\EPInterface'); |
| 162 | 162 | } |
| 163 | 163 | return $this; |
@@ -176,12 +176,12 @@ discard block |
||
| 176 | 176 | $EntryPoint = new $Class($this->apiURL, $params); |
| 177 | 177 | |
| 178 | 178 | if ($EntryPoint->authRequired()){ |
| 179 | - if (isset($this->token) && $this->authenticated()) { |
|
| 179 | + if (isset($this->token) && $this->authenticated()){ |
|
| 180 | 180 | $EntryPoint->setAuth($this->getToken()->access_token); |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | return $EntryPoint; |
| 184 | - }else{ |
|
| 184 | + } else{ |
|
| 185 | 185 | throw new EntryPointException($name,'Unregistered EntryPoint'); |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -190,13 +190,13 @@ discard block |
||
| 190 | 190 | * @inheritdoc |
| 191 | 191 | * @throws AuthenticationException - When Login request fails |
| 192 | 192 | */ |
| 193 | - public function login() { |
|
| 193 | + public function login(){ |
|
| 194 | 194 | $EP = new OAuth2Token($this->apiURL); |
| 195 | 195 | $response = $EP->execute($this->credentials)->getResponse(); |
| 196 | 196 | if ($response->getStatus()=='200'){ |
| 197 | 197 | $this->setToken($response->getBody(false)); |
| 198 | 198 | static::storeToken($this->token,$this->credentials['client_id']); |
| 199 | - } else { |
|
| 199 | + } else{ |
|
| 200 | 200 | $error = $response->getBody(); |
| 201 | 201 | throw new AuthenticationException("Login Response [".$error['error']."] ".$error['error_message']); |
| 202 | 202 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | if ($response->getStatus()=='200'){ |
| 219 | 219 | $this->setToken($response->getBody(false)); |
| 220 | 220 | static::storeToken($this->token,$this->credentials['client_id']); |
| 221 | - }else{ |
|
| 221 | + } else{ |
|
| 222 | 222 | $error = $response->getBody(); |
| 223 | 223 | throw new AuthenticationException("Refresh Response [".$error['error']."] ".$error['error_message']); |
| 224 | 224 | } |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | if ($response->getStatus()=='200'){ |
| 237 | 237 | unset($this->token); |
| 238 | 238 | static::removeStoredToken($this->credentials['client_id']); |
| 239 | - }else{ |
|
| 239 | + } else{ |
|
| 240 | 240 | $error = $response->getBody(); |
| 241 | 241 | throw new AuthenticationException("Logout Response [".$error['error']."] ".$error['message']); |
| 242 | 242 | } |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | /** |
| 248 | 248 | * @inheritdoc |
| 249 | 249 | */ |
| 250 | - public static function storeToken($token, $client_id) { |
|
| 250 | + public static function storeToken($token, $client_id){ |
|
| 251 | 251 | static::$_STORED_TOKENS[$client_id] = $token; |
| 252 | 252 | return true; |
| 253 | 253 | } |
@@ -255,14 +255,14 @@ discard block |
||
| 255 | 255 | /** |
| 256 | 256 | * @inheritdoc |
| 257 | 257 | */ |
| 258 | - public static function getStoredToken($client_id) { |
|
| 258 | + public static function getStoredToken($client_id){ |
|
| 259 | 259 | return static::$_STORED_TOKENS[$client_id]; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
| 263 | 263 | * @inheritdoc |
| 264 | 264 | */ |
| 265 | - public static function removeStoredToken($client_id) { |
|
| 265 | + public static function removeStoredToken($client_id){ |
|
| 266 | 266 | unset(static::$_STORED_TOKENS[$client_id]); |
| 267 | 267 | return true; |
| 268 | 268 | } |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | $EP = new OAuth2Token($this->apiURL); |
| 195 | 195 | $response = $EP->execute($this->credentials)->getResponse(); |
| 196 | 196 | if ($response->getStatus()=='200'){ |
| 197 | - $this->setToken($response->getBody(false)); |
|
| 197 | + $this->setToken($response->getBody(FALSE)); |
|
| 198 | 198 | static::storeToken($this->token,$this->credentials['client_id']); |
| 199 | 199 | } else { |
| 200 | 200 | $error = $response->getBody(); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $EP = new RefreshToken($this->apiURL); |
| 217 | 217 | $response = $EP->execute($refreshOptions)->getResponse(); |
| 218 | 218 | if ($response->getStatus()=='200'){ |
| 219 | - $this->setToken($response->getBody(false)); |
|
| 219 | + $this->setToken($response->getBody(FALSE)); |
|
| 220 | 220 | static::storeToken($this->token,$this->credentials['client_id']); |
| 221 | 221 | }else{ |
| 222 | 222 | $error = $response->getBody(); |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | public static function storeToken($token, $client_id) { |
| 251 | 251 | static::$_STORED_TOKENS[$client_id] = $token; |
| 252 | - return true; |
|
| 252 | + return TRUE; |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | */ |
| 265 | 265 | public static function removeStoredToken($client_id) { |
| 266 | 266 | unset(static::$_STORED_TOKENS[$client_id]); |
| 267 | - return true; |
|
| 267 | + return TRUE; |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | } |
| 271 | 271 | \ No newline at end of file |
@@ -17,8 +17,8 @@ |
||
| 17 | 17 | /** |
| 18 | 18 | * @inheritdoc |
| 19 | 19 | */ |
| 20 | - public function getBody($asArray = true) { |
|
| 21 | - return json_decode($this->body,$asArray); |
|
| 20 | + public function getBody($asArray = true){ |
|
| 21 | + return json_decode($this->body, $asArray); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | } |
| 25 | 25 | \ No newline at end of file |
@@ -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 | |
@@ -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 | |
@@ -8,8 +8,8 @@ |
||
| 8 | 8 | |
| 9 | 9 | protected $message = 'Authentication Exception [%s] occurred in SDK Client. Message: %s'; |
| 10 | 10 | |
| 11 | - public function __construct($message) { |
|
| 12 | - parent::__construct(sprintf($this->message,get_called_class(),$message)); |
|
| 11 | + public function __construct($message){ |
|
| 12 | + parent::__construct(sprintf($this->message, get_called_class(), $message)); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | } |
| 16 | 16 | \ No newline at end of file |
@@ -8,8 +8,8 @@ |
||
| 8 | 8 | |
| 9 | 9 | protected $message = 'EntryPoint Exception [%s] occurred on EntryPoint %s: %s'; |
| 10 | 10 | |
| 11 | - public function __construct($EntryPoint,$data) { |
|
| 12 | - parent::__construct(sprintf($this->message,get_called_class(),$EntryPoint,$data)); |
|
| 11 | + public function __construct($EntryPoint, $data){ |
|
| 12 | + parent::__construct(sprintf($this->message, get_called_class(), $EntryPoint, $data)); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | } |
| 16 | 16 | \ No newline at end of file |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | |
| 9 | 9 | protected $message = 'EntryPoint Exception [%s] occurred on EntryPoint %s: %s'; |
| 10 | 10 | |
| 11 | - public function __construct($EntryPoint,$data) { |
|
| 11 | + public function __construct($EntryPoint,$data){ |
|
| 12 | 12 | parent::__construct(sprintf($this->message,get_called_class(),$EntryPoint,$data)); |
| 13 | 13 | } |
| 14 | 14 | |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | * @param null $data |
| 59 | 59 | * @return mixed |
| 60 | 60 | */ |
| 61 | - public function execute($data = null); |
|
| 61 | + public function execute($data = NULL); |
|
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * Get the module that is set on the EntryPoint |
@@ -9,14 +9,14 @@ |
||
| 9 | 9 | |
| 10 | 10 | abstract class AbstractDeleteEntryPoint extends AbstractEntryPoint { |
| 11 | 11 | |
| 12 | - public function __construct($url, array $options = array()) { |
|
| 12 | + public function __construct($url, array $options = array()){ |
|
| 13 | 13 | $this->setRequest(new DELETE()); |
| 14 | 14 | parent::__construct($url, $options); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - public function execute($data = null) { |
|
| 17 | + public function execute($data = null){ |
|
| 18 | 18 | parent::execute($data); |
| 19 | - $this->setResponse(new JSON($this->Request->getResponse(),$this->Request->getCurlObject())); |
|
| 19 | + $this->setResponse(new JSON($this->Request->getResponse(), $this->Request->getCurlObject())); |
|
| 20 | 20 | return $this; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -9,12 +9,12 @@ |
||
| 9 | 9 | |
| 10 | 10 | abstract class AbstractDeleteEntryPoint extends AbstractEntryPoint { |
| 11 | 11 | |
| 12 | - public function __construct($url, array $options = array()) { |
|
| 12 | + public function __construct($url, array $options = array()){ |
|
| 13 | 13 | $this->setRequest(new DELETE()); |
| 14 | 14 | parent::__construct($url, $options); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - public function execute($data = null) { |
|
| 17 | + public function execute($data = null){ |
|
| 18 | 18 | parent::execute($data); |
| 19 | 19 | $this->setResponse(new JSON($this->Request->getResponse(),$this->Request->getCurlObject())); |
| 20 | 20 | return $this; |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | parent::__construct($url, $options); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - public function execute($data = null) { |
|
| 17 | + public function execute($data = NULL) { |
|
| 18 | 18 | parent::execute($data); |
| 19 | 19 | $this->setResponse(new JSON($this->Request->getResponse(),$this->Request->getCurlObject())); |
| 20 | 20 | return $this; |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | protected $accessToken; |
| 95 | 95 | |
| 96 | 96 | |
| 97 | - public function __construct($url,$options = array()){ |
|
| 97 | + public function __construct($url, $options = array()){ |
|
| 98 | 98 | $this->baseUrl = $url; |
| 99 | 99 | |
| 100 | - if (!empty($options)) { |
|
| 100 | + if (!empty($options)){ |
|
| 101 | 101 | $this->setOptions($options); |
| 102 | - }elseif(!$this->requiresOptions()){ |
|
| 102 | + }elseif (!$this->requiresOptions()){ |
|
| 103 | 103 | $this->configureURL(); |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function setData($data){ |
| 123 | 123 | $this->Data = $data; |
| 124 | - if ($this->verifyData()) { |
|
| 124 | + if ($this->verifyData()){ |
|
| 125 | 125 | $this->Request->setBody($data); |
| 126 | 126 | } |
| 127 | 127 | return $this; |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | /** |
| 131 | 131 | * @inheritdoc |
| 132 | 132 | */ |
| 133 | - public function setAuth($accessToken) { |
|
| 133 | + public function setAuth($accessToken){ |
|
| 134 | 134 | if ($this->authRequired()){ |
| 135 | 135 | $this->accessToken = $accessToken; |
| 136 | 136 | $this->Request->addHeader('OAuth-Token', $accessToken); |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | * @inheritdoc |
| 143 | 143 | * @throws InvalidURLException - When passed in URL contains $variables |
| 144 | 144 | */ |
| 145 | - public function setUrl($url) { |
|
| 145 | + public function setUrl($url){ |
|
| 146 | 146 | $this->Url = $url; |
| 147 | - if ($this->verifyUrl()) { |
|
| 147 | + if ($this->verifyUrl()){ |
|
| 148 | 148 | $this->Request->setURL($this->Url); |
| 149 | 149 | } |
| 150 | 150 | return $this; |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | /** |
| 154 | 154 | * @inheritdoc |
| 155 | 155 | */ |
| 156 | - public function setRequest(RequestInterface $Request) { |
|
| 156 | + public function setRequest(RequestInterface $Request){ |
|
| 157 | 157 | $this->Request = $Request; |
| 158 | 158 | return $this; |
| 159 | 159 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | /** |
| 162 | 162 | * @inheritdoc |
| 163 | 163 | */ |
| 164 | - public function setResponse(ResponseInterface $Response) { |
|
| 164 | + public function setResponse(ResponseInterface $Response){ |
|
| 165 | 165 | $this->Response = $Response; |
| 166 | 166 | return $this; |
| 167 | 167 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | /** |
| 170 | 170 | * @inheritdoc |
| 171 | 171 | */ |
| 172 | - public function getModule() { |
|
| 172 | + public function getModule(){ |
|
| 173 | 173 | return $this->Module; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | /** |
| 216 | 216 | * @inheritdoc |
| 217 | 217 | */ |
| 218 | - public function authRequired() { |
|
| 218 | + public function authRequired(){ |
|
| 219 | 219 | return $this->_AUTH_REQUIRED; |
| 220 | 220 | } |
| 221 | 221 | |
@@ -223,8 +223,8 @@ discard block |
||
| 223 | 223 | * Override function for configuring Default Values on some EntryPoints to allow for short hand |
| 224 | 224 | */ |
| 225 | 225 | protected function configureData($data){ |
| 226 | - if (!empty($this->_REQUIRED_DATA)&&is_array($data)){ |
|
| 227 | - foreach($this->_REQUIRED_DATA as $property => $value){ |
|
| 226 | + if (!empty($this->_REQUIRED_DATA) && is_array($data)){ |
|
| 227 | + foreach ($this->_REQUIRED_DATA as $property => $value){ |
|
| 228 | 228 | if (!isset($data[$property])){ |
| 229 | 229 | $data[$property] = $value; |
| 230 | 230 | } |
@@ -240,18 +240,18 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | protected function configureURL(){ |
| 242 | 242 | $url = $this->_URL; |
| 243 | - if ($this->requiresOptions()) { |
|
| 243 | + if ($this->requiresOptions()){ |
|
| 244 | 244 | $urlParts = explode("/", $this->_URL); |
| 245 | 245 | $o = 0; |
| 246 | - foreach ($urlParts as $key => $part) { |
|
| 247 | - if (strpos($part, "$") !== FALSE) { |
|
| 248 | - if (isset($this->Options[$o])) { |
|
| 246 | + foreach ($urlParts as $key => $part){ |
|
| 247 | + if (strpos($part, "$")!==FALSE){ |
|
| 248 | + if (isset($this->Options[$o])){ |
|
| 249 | 249 | $urlParts[$key] = $this->Options[$o]; |
| 250 | 250 | $o++; |
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | - $url = implode($urlParts,"/"); |
|
| 254 | + $url = implode($urlParts, "/"); |
|
| 255 | 255 | } |
| 256 | 256 | $url = $this->baseUrl.$url; |
| 257 | 257 | $this->setUrl($url); |
@@ -263,9 +263,9 @@ discard block |
||
| 263 | 263 | * @throws InvalidURLException |
| 264 | 264 | */ |
| 265 | 265 | protected function verifyUrl(){ |
| 266 | - $UrlArray = explode("?",$this->Url); |
|
| 267 | - if (strpos($UrlArray[0],"$") !== FALSE){ |
|
| 268 | - throw new InvalidURLException(get_called_class(),"Configured URL is ".$this->Url); |
|
| 266 | + $UrlArray = explode("?", $this->Url); |
|
| 267 | + if (strpos($UrlArray[0], "$")!==FALSE){ |
|
| 268 | + throw new InvalidURLException(get_called_class(), "Configured URL is ".$this->Url); |
|
| 269 | 269 | } |
| 270 | 270 | return true; |
| 271 | 271 | } |
@@ -276,11 +276,11 @@ discard block |
||
| 276 | 276 | * @throws RequiredOptionsException |
| 277 | 277 | */ |
| 278 | 278 | protected function verifyOptions(){ |
| 279 | - $urlVarCount = substr_count($this->_URL,"$"); |
|
| 279 | + $urlVarCount = substr_count($this->_URL, "$"); |
|
| 280 | 280 | $optionCount = 0; |
| 281 | 281 | $optionCount += count($this->Options); |
| 282 | 282 | if ($urlVarCount!==$optionCount){ |
| 283 | - throw new RequiredOptionsException(get_called_class(),"URL requires $urlVarCount options."); |
|
| 283 | + throw new RequiredOptionsException(get_called_class(), "URL requires $urlVarCount options."); |
|
| 284 | 284 | } |
| 285 | 285 | return true; |
| 286 | 286 | } |
@@ -291,20 +291,20 @@ discard block |
||
| 291 | 291 | * @throws RequiredDataException |
| 292 | 292 | */ |
| 293 | 293 | protected function verifyData(){ |
| 294 | - if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)) { |
|
| 295 | - if (gettype($this->Data) !== $this->_DATA_TYPE) { |
|
| 296 | - throw new RequiredDataException(get_called_class(),"Valid DataType is {$this->_DATA_TYPE}"); |
|
| 294 | + if (isset($this->_DATA_TYPE) || !empty($this->_DATA_TYPE)){ |
|
| 295 | + if (gettype($this->Data)!==$this->_DATA_TYPE){ |
|
| 296 | + throw new RequiredDataException(get_called_class(), "Valid DataType is {$this->_DATA_TYPE}"); |
|
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | if (!empty($this->_REQUIRED_DATA)){ |
| 300 | 300 | $errors = array(); |
| 301 | - foreach($this->_REQUIRED_DATA as $property => $defaultValue){ |
|
| 301 | + foreach ($this->_REQUIRED_DATA as $property => $defaultValue){ |
|
| 302 | 302 | if (!isset($this->Data[$property])){ |
| 303 | 303 | $errors[] = $property; |
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | if (count($errors)>0){ |
| 307 | - throw new RequiredDataException(get_called_class(),"Missing data for $errors"); |
|
| 307 | + throw new RequiredDataException(get_called_class(), "Missing data for $errors"); |
|
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | return true; |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * @return bool |
| 316 | 316 | */ |
| 317 | 317 | protected function requiresOptions(){ |
| 318 | - return strpos($this->_URL,"$") !== FALSE?TRUE:FALSE; |
|
| 318 | + return strpos($this->_URL, "$")!==FALSE?TRUE:FALSE; |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | } |
| 322 | 322 | \ No newline at end of file |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | public function __construct($url,$options = array()){ |
| 98 | 98 | $this->baseUrl = $url; |
| 99 | 99 | |
| 100 | - if (!empty($options)) { |
|
| 100 | + if (!empty($options)){ |
|
| 101 | 101 | $this->setOptions($options); |
| 102 | - }elseif(!$this->requiresOptions()){ |
|
| 102 | + } elseif(!$this->requiresOptions()){ |
|
| 103 | 103 | $this->configureURL(); |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function setData($data){ |
| 123 | 123 | $this->Data = $data; |
| 124 | - if ($this->verifyData()) { |
|
| 124 | + if ($this->verifyData()){ |
|
| 125 | 125 | $this->Request->setBody($data); |
| 126 | 126 | } |
| 127 | 127 | return $this; |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | /** |
| 131 | 131 | * @inheritdoc |
| 132 | 132 | */ |
| 133 | - public function setAuth($accessToken) { |
|
| 133 | + public function setAuth($accessToken){ |
|
| 134 | 134 | if ($this->authRequired()){ |
| 135 | 135 | $this->accessToken = $accessToken; |
| 136 | 136 | $this->Request->addHeader('OAuth-Token', $accessToken); |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | * @inheritdoc |
| 143 | 143 | * @throws InvalidURLException - When passed in URL contains $variables |
| 144 | 144 | */ |
| 145 | - public function setUrl($url) { |
|
| 145 | + public function setUrl($url){ |
|
| 146 | 146 | $this->Url = $url; |
| 147 | - if ($this->verifyUrl()) { |
|
| 147 | + if ($this->verifyUrl()){ |
|
| 148 | 148 | $this->Request->setURL($this->Url); |
| 149 | 149 | } |
| 150 | 150 | return $this; |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | /** |
| 154 | 154 | * @inheritdoc |
| 155 | 155 | */ |
| 156 | - public function setRequest(RequestInterface $Request) { |
|
| 156 | + public function setRequest(RequestInterface $Request){ |
|
| 157 | 157 | $this->Request = $Request; |
| 158 | 158 | return $this; |
| 159 | 159 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | /** |
| 162 | 162 | * @inheritdoc |
| 163 | 163 | */ |
| 164 | - public function setResponse(ResponseInterface $Response) { |
|
| 164 | + public function setResponse(ResponseInterface $Response){ |
|
| 165 | 165 | $this->Response = $Response; |
| 166 | 166 | return $this; |
| 167 | 167 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | /** |
| 170 | 170 | * @inheritdoc |
| 171 | 171 | */ |
| 172 | - public function getModule() { |
|
| 172 | + public function getModule(){ |
|
| 173 | 173 | return $this->Module; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | /** |
| 216 | 216 | * @inheritdoc |
| 217 | 217 | */ |
| 218 | - public function authRequired() { |
|
| 218 | + public function authRequired(){ |
|
| 219 | 219 | return $this->_AUTH_REQUIRED; |
| 220 | 220 | } |
| 221 | 221 | |
@@ -240,12 +240,12 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | protected function configureURL(){ |
| 242 | 242 | $url = $this->_URL; |
| 243 | - if ($this->requiresOptions()) { |
|
| 243 | + if ($this->requiresOptions()){ |
|
| 244 | 244 | $urlParts = explode("/", $this->_URL); |
| 245 | 245 | $o = 0; |
| 246 | - foreach ($urlParts as $key => $part) { |
|
| 247 | - if (strpos($part, "$") !== FALSE) { |
|
| 248 | - if (isset($this->Options[$o])) { |
|
| 246 | + foreach ($urlParts as $key => $part){ |
|
| 247 | + if (strpos($part, "$") !== FALSE){ |
|
| 248 | + if (isset($this->Options[$o])){ |
|
| 249 | 249 | $urlParts[$key] = $this->Options[$o]; |
| 250 | 250 | $o++; |
| 251 | 251 | } |
@@ -291,8 +291,8 @@ discard block |
||
| 291 | 291 | * @throws RequiredDataException |
| 292 | 292 | */ |
| 293 | 293 | protected function verifyData(){ |
| 294 | - if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)) { |
|
| 295 | - if (gettype($this->Data) !== $this->_DATA_TYPE) { |
|
| 294 | + if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)){ |
|
| 295 | + if (gettype($this->Data) !== $this->_DATA_TYPE){ |
|
| 296 | 296 | throw new RequiredDataException(get_called_class(),"Valid DataType is {$this->_DATA_TYPE}"); |
| 297 | 297 | } |
| 298 | 298 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * Whether or not Authentication is Required |
| 17 | 17 | * @var bool |
| 18 | 18 | */ |
| 19 | - protected $_AUTH_REQUIRED = true; |
|
| 19 | + protected $_AUTH_REQUIRED = TRUE; |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * The URL for the EntryPoint |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | /** |
| 205 | 205 | * @inheritdoc |
| 206 | 206 | */ |
| 207 | - public function execute($data = null){ |
|
| 208 | - if ($data!==null){ |
|
| 207 | + public function execute($data = NULL){ |
|
| 208 | + if ($data!==NULL){ |
|
| 209 | 209 | $this->configureData($data); |
| 210 | 210 | } |
| 211 | 211 | $this->Request->send(); |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | if (strpos($UrlArray[0],"$") !== FALSE){ |
| 268 | 268 | throw new InvalidURLException(get_called_class(),"Configured URL is ".$this->Url); |
| 269 | 269 | } |
| 270 | - return true; |
|
| 270 | + return TRUE; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | if ($urlVarCount!==$optionCount){ |
| 283 | 283 | throw new RequiredOptionsException(get_called_class(),"URL requires $urlVarCount options."); |
| 284 | 284 | } |
| 285 | - return true; |
|
| 285 | + return TRUE; |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | throw new RequiredDataException(get_called_class(),"Missing data for $errors"); |
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | - return true; |
|
| 310 | + return TRUE; |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | /** |
@@ -8,14 +8,14 @@ |
||
| 8 | 8 | |
| 9 | 9 | abstract class AbstractGetEntryPoint 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 GET()); |
| 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 AbstractGetEntryPoint 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 GET()); |
| 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; |
@@ -14,14 +14,14 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | protected $downloadDir = null; |
| 16 | 16 | |
| 17 | - public function __construct($url, array $options = array()) { |
|
| 17 | + public function __construct($url, array $options = array()){ |
|
| 18 | 18 | $this->setRequest(new GETFile()); |
| 19 | 19 | parent::__construct($url, $options); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public function execute($data = null) { |
|
| 22 | + public function execute($data = null){ |
|
| 23 | 23 | parent::execute($data); |
| 24 | - $this->setResponse(new FileResponse($this->Request->getResponse(),$this->Request->getCurlObject(),$this->downloadDir)); |
|
| 24 | + $this->setResponse(new FileResponse($this->Request->getResponse(), $this->Request->getCurlObject(), $this->downloadDir)); |
|
| 25 | 25 | return $this; |
| 26 | 26 | } |
| 27 | 27 | |
@@ -14,12 +14,12 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | protected $downloadDir = null; |
| 16 | 16 | |
| 17 | - public function __construct($url, array $options = array()) { |
|
| 17 | + public function __construct($url, array $options = array()){ |
|
| 18 | 18 | $this->setRequest(new GETFile()); |
| 19 | 19 | parent::__construct($url, $options); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public function execute($data = null) { |
|
| 22 | + public function execute($data = null){ |
|
| 23 | 23 | parent::execute($data); |
| 24 | 24 | $this->setResponse(new FileResponse($this->Request->getResponse(),$this->Request->getCurlObject(),$this->downloadDir)); |
| 25 | 25 | return $this; |
@@ -12,14 +12,14 @@ |
||
| 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 | public function __construct($url, array $options = array()) { |
| 18 | 18 | $this->setRequest(new GETFile()); |
| 19 | 19 | parent::__construct($url, $options); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public function execute($data = null) { |
|
| 22 | + public function execute($data = NULL) { |
|
| 23 | 23 | parent::execute($data); |
| 24 | 24 | $this->setResponse(new FileResponse($this->Request->getResponse(),$this->Request->getCurlObject(),$this->downloadDir)); |
| 25 | 25 | return $this; |