@@ -133,6 +133,7 @@ |
||
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | 135 | * @inheritdoc |
| 136 | + * @param string $body |
|
| 136 | 137 | */ |
| 137 | 138 | public function setBody($body) { |
| 138 | 139 | $this->body = $body; |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | /** |
| 91 | 91 | * Always make sure to destroy Curl Resource |
| 92 | 92 | */ |
| 93 | - public function __destruct() { |
|
| 93 | + public function __destruct(){ |
|
| 94 | 94 | if ($this->status!==self::STATUS_CLOSED){ |
| 95 | 95 | curl_close($this->CurlRequest); |
| 96 | 96 | } |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | /** |
| 91 | 91 | * Always make sure to destroy Curl Resource |
| 92 | 92 | */ |
| 93 | - public function __destruct() { |
|
| 93 | + public function __destruct(){ |
|
| 94 | 94 | if ($this->status!==self::STATUS_CLOSED){ |
| 95 | 95 | curl_close($this->CurlRequest); |
| 96 | 96 | } |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | class EntryPointException extends SDKException { |
| 6 | 6 | |
| 7 | - public function __construct($message) { |
|
| 7 | + public function __construct($message){ |
|
| 8 | 8 | parent::__construct($message); |
| 9 | 9 | } |
| 10 | 10 | |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | class EntryPointException extends SDKException { |
| 6 | 6 | |
| 7 | - public function __construct($message) { |
|
| 7 | + public function __construct($message){ |
|
| 8 | 8 | parent::__construct($message); |
| 9 | 9 | } |
| 10 | 10 | |
@@ -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 | |
@@ -151,7 +151,7 @@ |
||
| 151 | 151 | /** |
| 152 | 152 | * @param $funcName |
| 153 | 153 | * @param $className |
| 154 | - * @return bool |
|
| 154 | + * @return AbstractClient |
|
| 155 | 155 | * @throws EntryPointException |
| 156 | 156 | */ |
| 157 | 157 | public function registerEntryPoint($funcName, $className){ |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | protected $entryPoints = array(); |
| 65 | 65 | |
| 66 | - public function __construct($server = '',array $credentials = array()){ |
|
| 66 | + public function __construct($server = '', array $credentials = array()){ |
|
| 67 | 67 | $server = (empty($server)?$this->server:$server); |
| 68 | 68 | $this->setServer($server); |
| 69 | 69 | $credentials = (empty($credentials)?$this->credentials:$credentials); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @inheritdoc |
| 76 | 76 | * @param string $server |
| 77 | 77 | */ |
| 78 | - public function setServer($server) { |
|
| 78 | + public function setServer($server){ |
|
| 79 | 79 | $this->server = $server; |
| 80 | 80 | $this->apiURL = Helpers::configureAPIURL($this->server); |
| 81 | 81 | return $this; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | /** |
| 85 | 85 | * @inheritdoc |
| 86 | 86 | */ |
| 87 | - public function getAPIUrl() { |
|
| 87 | + public function getAPIUrl(){ |
|
| 88 | 88 | return $this->apiURL; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function setCredentials(array $credentials){ |
| 96 | 96 | $this->credentials = $credentials; |
| 97 | - if (isset($this->credentials['client_id'])) { |
|
| 97 | + if (isset($this->credentials['client_id'])){ |
|
| 98 | 98 | $token = static::getStoredToken($this->credentials['client_id']); |
| 99 | - if (!empty($token)) { |
|
| 99 | + if (!empty($token)){ |
|
| 100 | 100 | $this->setToken($token); |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | /** |
| 130 | 130 | * @inheritdoc |
| 131 | 131 | */ |
| 132 | - public function getServer() { |
|
| 132 | + public function getServer(){ |
|
| 133 | 133 | return $this->server; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @inheritdoc |
| 138 | 138 | */ |
| 139 | 139 | public function authenticated(){ |
| 140 | - return time() < $this->expiration; |
|
| 140 | + return time()<$this->expiration; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -159,10 +159,10 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function registerEntryPoint($funcName, $className){ |
| 161 | 161 | $implements = class_implements($className); |
| 162 | - if (is_array($implements) && in_array('SugarAPI\SDK\EntryPoint\Interfaces\EPInterface',$implements)){ |
|
| 162 | + if (is_array($implements) && in_array('SugarAPI\SDK\EntryPoint\Interfaces\EPInterface', $implements)){ |
|
| 163 | 163 | $this->entryPoints[$funcName] = $className; |
| 164 | 164 | }else{ |
| 165 | - throw new EntryPointException($className,'Class must extend SugarAPI\SDK\EntryPoint\Interfaces\EPInterface'); |
|
| 165 | + throw new EntryPointException($className, 'Class must extend SugarAPI\SDK\EntryPoint\Interfaces\EPInterface'); |
|
| 166 | 166 | } |
| 167 | 167 | return $this; |
| 168 | 168 | } |
@@ -180,13 +180,13 @@ discard block |
||
| 180 | 180 | $EntryPoint = new $Class($this->apiURL, $params); |
| 181 | 181 | |
| 182 | 182 | if ($EntryPoint->authRequired()){ |
| 183 | - if (isset($this->token) && $this->authenticated()) { |
|
| 183 | + if (isset($this->token) && $this->authenticated()){ |
|
| 184 | 184 | $EntryPoint->setAuth($this->getToken()->access_token); |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | return $EntryPoint; |
| 188 | 188 | }else{ |
| 189 | - throw new EntryPointException($name,'Unregistered EntryPoint'); |
|
| 189 | + throw new EntryPointException($name, 'Unregistered EntryPoint'); |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | |
@@ -194,13 +194,13 @@ discard block |
||
| 194 | 194 | * @inheritdoc |
| 195 | 195 | * @throws AuthenticationException - When Login request fails |
| 196 | 196 | */ |
| 197 | - public function login() { |
|
| 197 | + public function login(){ |
|
| 198 | 198 | $EP = new OAuth2Token($this->apiURL); |
| 199 | 199 | $response = $EP->execute($this->credentials)->getResponse(); |
| 200 | 200 | if ($response->getStatus()=='200'){ |
| 201 | 201 | $this->setToken($response->getBody(FALSE)); |
| 202 | - static::storeToken($this->token,$this->credentials['client_id']); |
|
| 203 | - } else { |
|
| 202 | + static::storeToken($this->token, $this->credentials['client_id']); |
|
| 203 | + }else{ |
|
| 204 | 204 | $error = $response->getBody(); |
| 205 | 205 | throw new AuthenticationException("Login Response [".$error['error']."] ".$error['error_message']); |
| 206 | 206 | } |
@@ -212,9 +212,9 @@ discard block |
||
| 212 | 212 | * @throws AuthenticationException - When Refresh Request fails |
| 213 | 213 | */ |
| 214 | 214 | public function refreshToken(){ |
| 215 | - if (isset($this->credentials['client_id'])&& |
|
| 216 | - isset($this->credentials['client_secret'])&& |
|
| 217 | - isset($this->token)) { |
|
| 215 | + if (isset($this->credentials['client_id']) && |
|
| 216 | + isset($this->credentials['client_secret']) && |
|
| 217 | + isset($this->token)){ |
|
| 218 | 218 | $refreshOptions = array( |
| 219 | 219 | 'client_id' => $this->credentials['client_id'], |
| 220 | 220 | 'client_secret' => $this->credentials['client_secret'], |
@@ -222,13 +222,13 @@ discard block |
||
| 222 | 222 | ); |
| 223 | 223 | $EP = new RefreshToken($this->apiURL); |
| 224 | 224 | $response = $EP->execute($refreshOptions)->getResponse(); |
| 225 | - if ($response->getStatus() == '200') { |
|
| 225 | + if ($response->getStatus()=='200'){ |
|
| 226 | 226 | $this->setToken($response->getBody(FALSE)); |
| 227 | 227 | static::storeToken($this->token, $this->credentials['client_id']); |
| 228 | 228 | return TRUE; |
| 229 | - } else { |
|
| 229 | + }else{ |
|
| 230 | 230 | $error = $response->getBody(); |
| 231 | - throw new AuthenticationException("Refresh Response [" . $error['error'] . "] " . $error['error_message']); |
|
| 231 | + throw new AuthenticationException("Refresh Response [".$error['error']."] ".$error['error_message']); |
|
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | 234 | return FALSE; |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * @inheritdoc |
| 259 | 259 | * @param \stdClass $token |
| 260 | 260 | */ |
| 261 | - public static function storeToken($token, $client_id) { |
|
| 261 | + public static function storeToken($token, $client_id){ |
|
| 262 | 262 | static::$_STORED_TOKENS[$client_id] = $token; |
| 263 | 263 | return TRUE; |
| 264 | 264 | } |
@@ -266,14 +266,14 @@ discard block |
||
| 266 | 266 | /** |
| 267 | 267 | * @inheritdoc |
| 268 | 268 | */ |
| 269 | - public static function getStoredToken($client_id) { |
|
| 269 | + public static function getStoredToken($client_id){ |
|
| 270 | 270 | return (isset(static::$_STORED_TOKENS[$client_id])?static::$_STORED_TOKENS[$client_id]:NULL); |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
| 274 | 274 | * @inheritdoc |
| 275 | 275 | */ |
| 276 | - public static function removeStoredToken($client_id) { |
|
| 276 | + public static function removeStoredToken($client_id){ |
|
| 277 | 277 | unset(static::$_STORED_TOKENS[$client_id]); |
| 278 | 278 | return TRUE; |
| 279 | 279 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @inheritdoc |
| 76 | 76 | * @param string $server |
| 77 | 77 | */ |
| 78 | - public function setServer($server) { |
|
| 78 | + public function setServer($server){ |
|
| 79 | 79 | $this->server = $server; |
| 80 | 80 | $this->apiURL = Helpers::configureAPIURL($this->server); |
| 81 | 81 | return $this; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | /** |
| 85 | 85 | * @inheritdoc |
| 86 | 86 | */ |
| 87 | - public function getAPIUrl() { |
|
| 87 | + public function getAPIUrl(){ |
|
| 88 | 88 | return $this->apiURL; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function setCredentials(array $credentials){ |
| 96 | 96 | $this->credentials = $credentials; |
| 97 | - if (isset($this->credentials['client_id'])) { |
|
| 97 | + if (isset($this->credentials['client_id'])){ |
|
| 98 | 98 | $token = static::getStoredToken($this->credentials['client_id']); |
| 99 | - if (!empty($token)) { |
|
| 99 | + if (!empty($token)){ |
|
| 100 | 100 | $this->setToken($token); |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | /** |
| 130 | 130 | * @inheritdoc |
| 131 | 131 | */ |
| 132 | - public function getServer() { |
|
| 132 | + public function getServer(){ |
|
| 133 | 133 | return $this->server; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $implements = class_implements($className); |
| 162 | 162 | if (is_array($implements) && in_array('SugarAPI\SDK\EntryPoint\Interfaces\EPInterface',$implements)){ |
| 163 | 163 | $this->entryPoints[$funcName] = $className; |
| 164 | - }else{ |
|
| 164 | + } else{ |
|
| 165 | 165 | throw new EntryPointException($className,'Class must extend SugarAPI\SDK\EntryPoint\Interfaces\EPInterface'); |
| 166 | 166 | } |
| 167 | 167 | return $this; |
@@ -180,12 +180,12 @@ discard block |
||
| 180 | 180 | $EntryPoint = new $Class($this->apiURL, $params); |
| 181 | 181 | |
| 182 | 182 | if ($EntryPoint->authRequired()){ |
| 183 | - if (isset($this->token) && $this->authenticated()) { |
|
| 183 | + if (isset($this->token) && $this->authenticated()){ |
|
| 184 | 184 | $EntryPoint->setAuth($this->getToken()->access_token); |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | return $EntryPoint; |
| 188 | - }else{ |
|
| 188 | + } else{ |
|
| 189 | 189 | throw new EntryPointException($name,'Unregistered EntryPoint'); |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -194,13 +194,13 @@ discard block |
||
| 194 | 194 | * @inheritdoc |
| 195 | 195 | * @throws AuthenticationException - When Login request fails |
| 196 | 196 | */ |
| 197 | - public function login() { |
|
| 197 | + public function login(){ |
|
| 198 | 198 | $EP = new OAuth2Token($this->apiURL); |
| 199 | 199 | $response = $EP->execute($this->credentials)->getResponse(); |
| 200 | 200 | if ($response->getStatus()=='200'){ |
| 201 | 201 | $this->setToken($response->getBody(FALSE)); |
| 202 | 202 | static::storeToken($this->token,$this->credentials['client_id']); |
| 203 | - } else { |
|
| 203 | + } else{ |
|
| 204 | 204 | $error = $response->getBody(); |
| 205 | 205 | throw new AuthenticationException("Login Response [".$error['error']."] ".$error['error_message']); |
| 206 | 206 | } |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | public function refreshToken(){ |
| 215 | 215 | if (isset($this->credentials['client_id'])&& |
| 216 | 216 | isset($this->credentials['client_secret'])&& |
| 217 | - isset($this->token)) { |
|
| 217 | + isset($this->token)){ |
|
| 218 | 218 | $refreshOptions = array( |
| 219 | 219 | 'client_id' => $this->credentials['client_id'], |
| 220 | 220 | 'client_secret' => $this->credentials['client_secret'], |
@@ -222,11 +222,11 @@ discard block |
||
| 222 | 222 | ); |
| 223 | 223 | $EP = new RefreshToken($this->apiURL); |
| 224 | 224 | $response = $EP->execute($refreshOptions)->getResponse(); |
| 225 | - if ($response->getStatus() == '200') { |
|
| 225 | + if ($response->getStatus() == '200'){ |
|
| 226 | 226 | $this->setToken($response->getBody(FALSE)); |
| 227 | 227 | static::storeToken($this->token, $this->credentials['client_id']); |
| 228 | 228 | return TRUE; |
| 229 | - } else { |
|
| 229 | + } else{ |
|
| 230 | 230 | $error = $response->getBody(); |
| 231 | 231 | throw new AuthenticationException("Refresh Response [" . $error['error'] . "] " . $error['error_message']); |
| 232 | 232 | } |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | unset($this->token); |
| 247 | 247 | static::removeStoredToken($this->credentials['client_id']); |
| 248 | 248 | return TRUE; |
| 249 | - }else{ |
|
| 249 | + } else{ |
|
| 250 | 250 | $error = $response->getBody(); |
| 251 | 251 | throw new AuthenticationException("Logout Response [".$error['error']."] ".$error['message']); |
| 252 | 252 | } |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * @inheritdoc |
| 259 | 259 | * @param \stdClass $token |
| 260 | 260 | */ |
| 261 | - public static function storeToken($token, $client_id) { |
|
| 261 | + public static function storeToken($token, $client_id){ |
|
| 262 | 262 | static::$_STORED_TOKENS[$client_id] = $token; |
| 263 | 263 | return TRUE; |
| 264 | 264 | } |
@@ -266,14 +266,14 @@ discard block |
||
| 266 | 266 | /** |
| 267 | 267 | * @inheritdoc |
| 268 | 268 | */ |
| 269 | - public static function getStoredToken($client_id) { |
|
| 269 | + public static function getStoredToken($client_id){ |
|
| 270 | 270 | return (isset(static::$_STORED_TOKENS[$client_id])?static::$_STORED_TOKENS[$client_id]:NULL); |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
| 274 | 274 | * @inheritdoc |
| 275 | 275 | */ |
| 276 | - public static function removeStoredToken($client_id) { |
|
| 276 | + public static function removeStoredToken($client_id){ |
|
| 277 | 277 | unset(static::$_STORED_TOKENS[$client_id]); |
| 278 | 278 | return TRUE; |
| 279 | 279 | } |
@@ -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 | |
@@ -116,10 +116,10 @@ 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 | 124 | } |
| 125 | 125 | $this->configureURL(); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | /** |
| 147 | 147 | * @inheritdoc |
| 148 | 148 | */ |
| 149 | - public function setAuth($accessToken) { |
|
| 149 | + public function setAuth($accessToken){ |
|
| 150 | 150 | $this->accessToken = $accessToken; |
| 151 | 151 | return $this; |
| 152 | 152 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | /** |
| 155 | 155 | * @inheritdoc |
| 156 | 156 | */ |
| 157 | - public function setUrl($url) { |
|
| 157 | + public function setUrl($url){ |
|
| 158 | 158 | $this->Url = $url; |
| 159 | 159 | return $this; |
| 160 | 160 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | /** |
| 163 | 163 | * @inheritdoc |
| 164 | 164 | */ |
| 165 | - public function setRequest(RequestInterface $Request) { |
|
| 165 | + public function setRequest(RequestInterface $Request){ |
|
| 166 | 166 | $this->Request = $Request; |
| 167 | 167 | return $this; |
| 168 | 168 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | /** |
| 171 | 171 | * @inheritdoc |
| 172 | 172 | */ |
| 173 | - public function setResponse(ResponseInterface $Response) { |
|
| 173 | + public function setResponse(ResponseInterface $Response){ |
|
| 174 | 174 | $this->Response = $Response; |
| 175 | 175 | return $this; |
| 176 | 176 | } |
@@ -218,13 +218,13 @@ discard block |
||
| 218 | 218 | * @throws InvalidURLException |
| 219 | 219 | */ |
| 220 | 220 | public function execute($data = NULL){ |
| 221 | - $data = ($data === NULL?$this->Data:$data); |
|
| 221 | + $data = ($data===NULL?$this->Data:$data); |
|
| 222 | 222 | $this->configureData($data); |
| 223 | - if (is_object($this->Request)) { |
|
| 223 | + if (is_object($this->Request)){ |
|
| 224 | 224 | $this->configureRequest(); |
| 225 | 225 | $this->Request->send(); |
| 226 | 226 | }else{ |
| 227 | - throw new InvalidRequestException(get_called_class(),"Request property not configured"); |
|
| 227 | + throw new InvalidRequestException(get_called_class(), "Request property not configured"); |
|
| 228 | 228 | } |
| 229 | 229 | return $this; |
| 230 | 230 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | /** |
| 233 | 233 | * @inheritdoc |
| 234 | 234 | */ |
| 235 | - public function authRequired() { |
|
| 235 | + public function authRequired(){ |
|
| 236 | 236 | return $this->_AUTH_REQUIRED; |
| 237 | 237 | } |
| 238 | 238 | |
@@ -242,10 +242,10 @@ discard block |
||
| 242 | 242 | * @throws RequiredDataException |
| 243 | 243 | */ |
| 244 | 244 | protected function configureRequest(){ |
| 245 | - if ($this->verifyUrl()) { |
|
| 245 | + if ($this->verifyUrl()){ |
|
| 246 | 246 | $this->Request->setURL($this->Url); |
| 247 | 247 | } |
| 248 | - if ($this->verifyData() && !empty($this->Data)) { |
|
| 248 | + if ($this->verifyData() && !empty($this->Data)){ |
|
| 249 | 249 | $this->Request->setBody($this->Data); |
| 250 | 250 | } |
| 251 | 251 | $this->configureAuth(); |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * Configures the authentication header on the Request object |
| 256 | 256 | */ |
| 257 | 257 | protected function configureAuth(){ |
| 258 | - if ($this->authRequired()) { |
|
| 258 | + if ($this->authRequired()){ |
|
| 259 | 259 | $this->Request->addHeader('OAuth-Token', $this->accessToken); |
| 260 | 260 | } |
| 261 | 261 | } |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * @var $data |
| 266 | 266 | */ |
| 267 | 267 | protected function configureData($data){ |
| 268 | - if (!empty($this->_REQUIRED_DATA)&&is_array($data)){ |
|
| 268 | + if (!empty($this->_REQUIRED_DATA) && is_array($data)){ |
|
| 269 | 269 | $data = $this->configureDefaultData($data); |
| 270 | 270 | } |
| 271 | 271 | $this->setData($data); |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | * @return array |
| 278 | 278 | */ |
| 279 | 279 | protected function configureDefaultData(array $data){ |
| 280 | - foreach($this->_REQUIRED_DATA as $property => $value){ |
|
| 280 | + foreach ($this->_REQUIRED_DATA as $property => $value){ |
|
| 281 | 281 | if (!isset($data[$property]) && $value!==NULL){ |
| 282 | 282 | $data[$property] = $value; |
| 283 | 283 | } |
@@ -292,18 +292,18 @@ discard block |
||
| 292 | 292 | */ |
| 293 | 293 | protected function configureURL(){ |
| 294 | 294 | $url = $this->_URL; |
| 295 | - if ($this->requiresOptions()) { |
|
| 295 | + if ($this->requiresOptions()){ |
|
| 296 | 296 | $urlParts = explode("/", $this->_URL); |
| 297 | 297 | $o = 0; |
| 298 | - foreach ($urlParts as $key => $part) { |
|
| 299 | - if (strpos($part, "$") !== FALSE) { |
|
| 300 | - if (isset($this->Options[$o])) { |
|
| 298 | + foreach ($urlParts as $key => $part){ |
|
| 299 | + if (strpos($part, "$")!==FALSE){ |
|
| 300 | + if (isset($this->Options[$o])){ |
|
| 301 | 301 | $urlParts[$key] = $this->Options[$o]; |
| 302 | 302 | $o++; |
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | - $url = implode($urlParts,"/"); |
|
| 306 | + $url = implode($urlParts, "/"); |
|
| 307 | 307 | } |
| 308 | 308 | $url = $this->baseUrl.$url; |
| 309 | 309 | $this->setUrl($url); |
@@ -315,9 +315,9 @@ discard block |
||
| 315 | 315 | * @throws InvalidURLException |
| 316 | 316 | */ |
| 317 | 317 | protected function verifyUrl(){ |
| 318 | - $UrlArray = explode("?",$this->Url); |
|
| 319 | - if (strpos($UrlArray[0],"$") !== FALSE){ |
|
| 320 | - throw new InvalidURLException(get_called_class(),"Configured URL is ".$this->Url); |
|
| 318 | + $UrlArray = explode("?", $this->Url); |
|
| 319 | + if (strpos($UrlArray[0], "$")!==FALSE){ |
|
| 320 | + throw new InvalidURLException(get_called_class(), "Configured URL is ".$this->Url); |
|
| 321 | 321 | } |
| 322 | 322 | return true; |
| 323 | 323 | } |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | * @throws RequiredDataException |
| 329 | 329 | */ |
| 330 | 330 | protected function verifyData(){ |
| 331 | - if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)) { |
|
| 331 | + if (isset($this->_DATA_TYPE) || !empty($this->_DATA_TYPE)){ |
|
| 332 | 332 | $this->verifyDataType(); |
| 333 | 333 | } |
| 334 | 334 | if (!empty($this->_REQUIRED_DATA)){ |
@@ -343,8 +343,8 @@ discard block |
||
| 343 | 343 | * @throws RequiredDataException |
| 344 | 344 | */ |
| 345 | 345 | protected function verifyDataType(){ |
| 346 | - if (gettype($this->Data) !== $this->_DATA_TYPE) { |
|
| 347 | - throw new RequiredDataException(get_called_class(),"Valid DataType is {$this->_DATA_TYPE}"); |
|
| 346 | + if (gettype($this->Data)!==$this->_DATA_TYPE){ |
|
| 347 | + throw new RequiredDataException(get_called_class(), "Valid DataType is {$this->_DATA_TYPE}"); |
|
| 348 | 348 | } |
| 349 | 349 | return true; |
| 350 | 350 | } |
@@ -356,13 +356,13 @@ discard block |
||
| 356 | 356 | */ |
| 357 | 357 | protected function verifyRequiredData(){ |
| 358 | 358 | $errors = array(); |
| 359 | - foreach($this->_REQUIRED_DATA as $property => $defaultValue){ |
|
| 359 | + foreach ($this->_REQUIRED_DATA as $property => $defaultValue){ |
|
| 360 | 360 | if (!isset($this->Data[$property])){ |
| 361 | 361 | $errors[] = $property; |
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | if (count($errors)>0){ |
| 365 | - throw new RequiredDataException(get_called_class(),"Missing data for ".implode(",",$errors)); |
|
| 365 | + throw new RequiredDataException(get_called_class(), "Missing data for ".implode(",", $errors)); |
|
| 366 | 366 | } |
| 367 | 367 | return true; |
| 368 | 368 | } |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | * @return bool |
| 373 | 373 | */ |
| 374 | 374 | protected function requiresOptions(){ |
| 375 | - return strpos($this->_URL,"$") === FALSE?FALSE:TRUE; |
|
| 375 | + return strpos($this->_URL, "$")===FALSE?FALSE:TRUE; |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | } |
| 379 | 379 | \ No newline at end of file |
@@ -119,7 +119,7 @@ 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 | 124 | } |
| 125 | 125 | $this->configureURL(); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | /** |
| 147 | 147 | * @inheritdoc |
| 148 | 148 | */ |
| 149 | - public function setAuth($accessToken) { |
|
| 149 | + public function setAuth($accessToken){ |
|
| 150 | 150 | $this->accessToken = $accessToken; |
| 151 | 151 | return $this; |
| 152 | 152 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | /** |
| 155 | 155 | * @inheritdoc |
| 156 | 156 | */ |
| 157 | - public function setUrl($url) { |
|
| 157 | + public function setUrl($url){ |
|
| 158 | 158 | $this->Url = $url; |
| 159 | 159 | return $this; |
| 160 | 160 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | /** |
| 163 | 163 | * @inheritdoc |
| 164 | 164 | */ |
| 165 | - public function setRequest(RequestInterface $Request) { |
|
| 165 | + public function setRequest(RequestInterface $Request){ |
|
| 166 | 166 | $this->Request = $Request; |
| 167 | 167 | return $this; |
| 168 | 168 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | /** |
| 171 | 171 | * @inheritdoc |
| 172 | 172 | */ |
| 173 | - public function setResponse(ResponseInterface $Response) { |
|
| 173 | + public function setResponse(ResponseInterface $Response){ |
|
| 174 | 174 | $this->Response = $Response; |
| 175 | 175 | return $this; |
| 176 | 176 | } |
@@ -220,10 +220,10 @@ discard block |
||
| 220 | 220 | public function execute($data = NULL){ |
| 221 | 221 | $data = ($data === NULL?$this->Data:$data); |
| 222 | 222 | $this->configureData($data); |
| 223 | - if (is_object($this->Request)) { |
|
| 223 | + if (is_object($this->Request)){ |
|
| 224 | 224 | $this->configureRequest(); |
| 225 | 225 | $this->Request->send(); |
| 226 | - }else{ |
|
| 226 | + } else{ |
|
| 227 | 227 | throw new InvalidRequestException(get_called_class(),"Request property not configured"); |
| 228 | 228 | } |
| 229 | 229 | return $this; |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | /** |
| 233 | 233 | * @inheritdoc |
| 234 | 234 | */ |
| 235 | - public function authRequired() { |
|
| 235 | + public function authRequired(){ |
|
| 236 | 236 | return $this->_AUTH_REQUIRED; |
| 237 | 237 | } |
| 238 | 238 | |
@@ -242,10 +242,10 @@ discard block |
||
| 242 | 242 | * @throws RequiredDataException |
| 243 | 243 | */ |
| 244 | 244 | protected function configureRequest(){ |
| 245 | - if ($this->verifyUrl()) { |
|
| 245 | + if ($this->verifyUrl()){ |
|
| 246 | 246 | $this->Request->setURL($this->Url); |
| 247 | 247 | } |
| 248 | - if ($this->verifyData() && !empty($this->Data)) { |
|
| 248 | + if ($this->verifyData() && !empty($this->Data)){ |
|
| 249 | 249 | $this->Request->setBody($this->Data); |
| 250 | 250 | } |
| 251 | 251 | $this->configureAuth(); |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * Configures the authentication header on the Request object |
| 256 | 256 | */ |
| 257 | 257 | protected function configureAuth(){ |
| 258 | - if ($this->authRequired()) { |
|
| 258 | + if ($this->authRequired()){ |
|
| 259 | 259 | $this->Request->addHeader('OAuth-Token', $this->accessToken); |
| 260 | 260 | } |
| 261 | 261 | } |
@@ -292,12 +292,12 @@ discard block |
||
| 292 | 292 | */ |
| 293 | 293 | protected function configureURL(){ |
| 294 | 294 | $url = $this->_URL; |
| 295 | - if ($this->requiresOptions()) { |
|
| 295 | + if ($this->requiresOptions()){ |
|
| 296 | 296 | $urlParts = explode("/", $this->_URL); |
| 297 | 297 | $o = 0; |
| 298 | - foreach ($urlParts as $key => $part) { |
|
| 299 | - if (strpos($part, "$") !== FALSE) { |
|
| 300 | - if (isset($this->Options[$o])) { |
|
| 298 | + foreach ($urlParts as $key => $part){ |
|
| 299 | + if (strpos($part, "$") !== FALSE){ |
|
| 300 | + if (isset($this->Options[$o])){ |
|
| 301 | 301 | $urlParts[$key] = $this->Options[$o]; |
| 302 | 302 | $o++; |
| 303 | 303 | } |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | * @throws RequiredDataException |
| 329 | 329 | */ |
| 330 | 330 | protected function verifyData(){ |
| 331 | - if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)) { |
|
| 331 | + if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)){ |
|
| 332 | 332 | $this->verifyDataType(); |
| 333 | 333 | } |
| 334 | 334 | if (!empty($this->_REQUIRED_DATA)){ |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | * @throws RequiredDataException |
| 344 | 344 | */ |
| 345 | 345 | protected function verifyDataType(){ |
| 346 | - if (gettype($this->Data) !== $this->_DATA_TYPE) { |
|
| 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 | 349 | 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 |
@@ -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 | /** |
@@ -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 | } |