| @@ -7,11 +7,17 @@ | ||
| 7 | 7 | protected $defaultMessage = 'Unknown SugarAPI SDK Exception Occurred.'; | 
| 8 | 8 | protected $failureCodes = array(); | 
| 9 | 9 | |
| 10 | + /** | |
| 11 | + * @param string $code | |
| 12 | + */ | |
| 10 | 13 |      public function __construct($code) { | 
| 11 | 14 | $message = $this->convertCode($code); | 
| 12 | 15 | parent::__construct($message); | 
| 13 | 16 | } | 
| 14 | 17 | |
| 18 | + /** | |
| 19 | + * @return string|null | |
| 20 | + */ | |
| 15 | 21 |      protected function convertCode($code,$string=''){ | 
| 16 | 22 |          if (array_key_exists($code,$this->failureCodes)){ | 
| 17 | 23 | return $this->failureCodes[$code]; | 
| @@ -15,7 +15,7 @@ | ||
| 15 | 15 |      protected function convertCode($code,$string=''){ | 
| 16 | 16 |          if (array_key_exists($code,$this->failureCodes)){ | 
| 17 | 17 | return $this->failureCodes[$code]; | 
| 18 | -        }else{ | |
| 18 | +        } else{ | |
| 19 | 19 | return $this->defaultMessage; | 
| 20 | 20 | } | 
| 21 | 21 | } | 
| @@ -64,7 +64,7 @@ discard block | ||
| 64 | 64 | require __DIR__ .DIRECTORY_SEPARATOR.'EntryPoint' .DIRECTORY_SEPARATOR.'registry.php'; | 
| 65 | 65 |          if (isset($entryPoints)){ | 
| 66 | 66 | $this->entryPoints = $entryPoints; | 
| 67 | -        }else{ | |
| 67 | +        } else{ | |
| 68 | 68 |              throw new InitializationFailure('no_ep_registry'); | 
| 69 | 69 | } | 
| 70 | 70 | } | 
| @@ -77,12 +77,12 @@ discard block | ||
| 77 | 77 |              if ($EntryPoint->authRequired()){ | 
| 78 | 78 |                  if (isset($this->authToken)) { | 
| 79 | 79 |                      $EntryPoint->getRequest()->addHeader('OAuth-Token', $this->authToken->access_token); | 
| 80 | -                }else{ | |
| 80 | +                } else{ | |
| 81 | 81 |                      throw new AuthenticationError('no_auth'); | 
| 82 | 82 | } | 
| 83 | 83 | } | 
| 84 | 84 | return $EntryPoint; | 
| 85 | -        }else{ | |
| 85 | +        } else{ | |
| 86 | 86 |              throw new InvalidEntryPoint('invalid_ep'); | 
| 87 | 87 | } | 
| 88 | 88 | } | 
| @@ -94,7 +94,7 @@ discard block | ||
| 94 | 94 | $response = $EP->data($this->authOptions)->execute()->getResponse(); | 
| 95 | 95 |          if ($response->getStatus()=='200'){ | 
| 96 | 96 | $this->authToken = $response->getBody(); | 
| 97 | -        }else{ | |
| 97 | +        } else{ | |
| 98 | 98 |              throw new AuthenticationError('failed_auth'); | 
| 99 | 99 | } | 
| 100 | 100 | } | 
| @@ -189,10 +189,10 @@ discard block | ||
| 189 | 189 |          if ($urlVarCount!==$optionCount){ | 
| 190 | 190 |              if (empty($this->Module)){ | 
| 191 | 191 |                  throw new EntryPointExecutionFailure('missing_module'); | 
| 192 | -            }else{ | |
| 192 | +            } else{ | |
| 193 | 193 |                  throw new EntryPointExecutionFailure('missing_options'); | 
| 194 | 194 | } | 
| 195 | -        }else{ | |
| 195 | +        } else{ | |
| 196 | 196 | return true; | 
| 197 | 197 | } | 
| 198 | 198 | } | 
| @@ -203,18 +203,18 @@ discard block | ||
| 203 | 203 |      protected function validateData(){ | 
| 204 | 204 |          if (empty($this->_REQUIRED_DATA)||count($this->_REQUIRED_DATA)==0){ | 
| 205 | 205 | return true; | 
| 206 | -        }else{ | |
| 206 | +        } else{ | |
| 207 | 207 | $errors = array(); | 
| 208 | 208 |              foreach($this->_REQUIRED_DATA as $property){ | 
| 209 | 209 |                  if (isset($this->Data[$property]) || $this->Data[$property]!==null){ | 
| 210 | 210 | continue; | 
| 211 | -                }else{ | |
| 211 | +                } else{ | |
| 212 | 212 | $errors[] = $property; | 
| 213 | 213 | } | 
| 214 | 214 | } | 
| 215 | 215 |              if (count($errors)>0){ | 
| 216 | 216 |                  throw new EntryPointExecutionFailure('missing_data'); | 
| 217 | -            }else{ | |
| 217 | +            } else{ | |
| 218 | 218 | return true; | 
| 219 | 219 | } | 
| 220 | 220 | } | 
| @@ -10,10 +10,10 @@ | ||
| 10 | 10 | $response = $EP->execute()->getResponse(); | 
| 11 | 11 |      if ($response->getStatus()=='200'){ | 
| 12 | 12 | print_r($response->getBody()); | 
| 13 | -    }else{ | |
| 13 | +    } else{ | |
| 14 | 14 | print_r($EP); | 
| 15 | 15 | print_r($response->getBody()); | 
| 16 | 16 | } | 
| 17 | -}catch(\SugarAPI\SDK\Exception\AuthenticationError $ex){ | |
| 17 | +} catch(\SugarAPI\SDK\Exception\AuthenticationError $ex){ | |
| 18 | 18 | print $ex->getMessage(); | 
| 19 | 19 | } | 
| @@ -15,7 +15,7 @@ | ||
| 15 | 15 | ))->execute()->getResponse()->getBody(); | 
| 16 | 16 | echo "Updated Record: ".$record->id; | 
| 17 | 17 | |
| 18 | -}catch(\SugarAPI\SDK\Exception\AuthenticationError $ex){ | |
| 18 | +} catch(\SugarAPI\SDK\Exception\AuthenticationError $ex){ | |
| 19 | 19 | print $ex->getMessage(); | 
| 20 | 20 | } | 
| 21 | 21 | |
| @@ -19,6 +19,6 @@ | ||
| 19 | 19 | print_r($getResponse->getBody()); | 
| 20 | 20 | } | 
| 21 | 21 | |
| 22 | -}catch(\SugarAPI\SDK\Exception\AuthenticationError $ex){ | |
| 22 | +} catch(\SugarAPI\SDK\Exception\AuthenticationError $ex){ | |
| 23 | 23 | print $ex->getMessage(); | 
| 24 | 24 | } | 
| 25 | 25 | \ No newline at end of file | 
| @@ -15,7 +15,7 @@ | ||
| 15 | 15 | ))->execute()->getResponse()->getBody(); | 
| 16 | 16 | echo "Updated Record: ".$record->id; | 
| 17 | 17 | |
| 18 | -}catch(\SugarAPI\SDK\Exception\AuthenticationError $ex){ | |
| 18 | +} catch(\SugarAPI\SDK\Exception\AuthenticationError $ex){ | |
| 19 | 19 | print $ex->getMessage(); | 
| 20 | 20 | } | 
| 21 | 21 | |