Completed
Push — master ( c7c88d...7873ee )
by Mike
02:24
created
src/Client/Abstracts/AbstractClient.php 2 patches
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,6 +72,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
Braces   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Response/JSON.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Exception/EntryPoint/EntryPointException.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/EntryPoint/Abstracts/DELETE/AbstractDeleteEntryPoint.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/EntryPoint/Abstracts/AbstractEntryPoint.php 1 patch
Braces   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/EntryPoint/Abstracts/GET/AbstractGetEntryPoint.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/EntryPoint/Abstracts/GET/AbstractGetFileEntryPoint.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/EntryPoint/Abstracts/PUT/AbstractPutEntryPoint.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@
 block discarded – undo
8 8
 
9 9
 abstract class AbstractPutEntryPoint 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 PUT());
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;
Please login to merge, or discard this patch.
src/EntryPoint/Abstracts/POST/AbstractPostEntryPoint.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@
 block discarded – undo
8 8
 
9 9
 abstract class AbstractPostEntryPoint 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 POST());
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;
Please login to merge, or discard this patch.