Completed
Push — master ( e6cd79...15515b )
by Mike
02:12
created
src/EntryPoint/Abstracts/AbstractEntryPoint.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
     protected $Request;
23 23
     protected $Response;
24 24
 
25
-    public function __construct($url,$options = array()){
25
+    public function __construct($url, $options = array()) {
26 26
         $this->url = $url;
27 27
         $this->Module = $this->_MODULE;
28 28
 
29 29
         if (!empty($options)) {
30 30
             if (empty($this->Module)) {
31
-                if (strpos($this->_URL, '$module') !== FALSE) {
31
+                if (strpos($this->_URL, '$module')!==FALSE) {
32 32
                     $this->module($options[0]);
33 33
                     array_shift($options);
34 34
                 }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     /**
42 42
      * @inheritdoc
43 43
      */
44
-    public function module($module){
44
+    public function module($module) {
45 45
         $this->Module = $module;
46 46
         return $this;
47 47
     }
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     /**
50 50
      * @inheritdoc
51 51
      */
52
-    public function options(array $options){
52
+    public function options(array $options) {
53 53
         $this->Options = $options;
54 54
         return $this;
55 55
     }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     /**
58 58
      * @inheritdoc
59 59
      */
60
-    public function data(array $data){
60
+    public function data(array $data) {
61 61
         $this->Data = $data;
62 62
         $this->Request->setBody($this->Data);
63 63
         return $this;
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     /**
67 67
      * @inheritdoc
68 68
      */
69
-    public function execute(){
69
+    public function execute() {
70 70
         if ($this->verifyURL() && $this->validateData()) {
71 71
             $this->configureURL();
72 72
             $this->Request->setURL($this->url);
@@ -96,28 +96,28 @@  discard block
 block discarded – undo
96 96
     /**
97 97
      *
98 98
      */
99
-    public function getData(){
99
+    public function getData() {
100 100
         return $this->Data;
101 101
     }
102 102
 
103 103
     /**
104 104
      * @inheritdoc
105 105
      */
106
-    public function getURL(){
106
+    public function getURL() {
107 107
         return $this->url;
108 108
     }
109 109
 
110 110
     /**
111 111
      * @inheritdoc
112 112
      */
113
-    public function getResponse(){
113
+    public function getResponse() {
114 114
         return $this->Response;
115 115
     }
116 116
 
117 117
     /**
118 118
      * @inheritdoc
119 119
      */
120
-    public function getRequest(){
120
+    public function getRequest() {
121 121
         return $this->Request;
122 122
     }
123 123
 
@@ -126,32 +126,32 @@  discard block
 block discarded – undo
126 126
      * - Replaces $module with $this->Module
127 127
      * - Replcaes all other variables starting with $, with options in the order they were given
128 128
      */
129
-    protected function configureURL(){
129
+    protected function configureURL() {
130 130
         $url = $this->_URL;
131
-        if (strpos($this->_URL,"$")!==FALSE) {
132
-            if (count($this->Options) > 0 || !empty($this->Module)) {
131
+        if (strpos($this->_URL, "$")!==FALSE) {
132
+            if (count($this->Options)>0 || !empty($this->Module)) {
133 133
                 $urlParts = explode("/", $this->_URL);
134 134
                 $o = 0;
135 135
                 foreach ($urlParts as $key => $part) {
136
-                    if (strpos($part, '$module') !== FALSE) {
136
+                    if (strpos($part, '$module')!==FALSE) {
137 137
                         if (isset($this->Module)) {
138 138
                             $urlParts[$key] = $this->Module;
139 139
                             continue;
140
-                        } else {
140
+                        }else {
141 141
                             if (isset($this->Options[$o])) {
142 142
                                 $this->Module = $this->Options[$o];
143 143
                                 array_shift($this->Options);
144 144
                             }
145 145
                         }
146 146
                     }
147
-                    if (strpos($part, "$") !== FALSE) {
147
+                    if (strpos($part, "$")!==FALSE) {
148 148
                         if (isset($this->Options[$o])) {
149 149
                             $urlParts[$key] = $this->Options[$o];
150 150
                             $o++;
151 151
                         }
152 152
                     }
153 153
                 }
154
-                $url = implode($urlParts,"/");
154
+                $url = implode($urlParts, "/");
155 155
             }
156 156
         }
157 157
         $this->url = $this->url.$url;
@@ -160,15 +160,15 @@  discard block
 block discarded – undo
160 160
     /**
161 161
      * Setup the Request Object property, setup on initial Construct of EntryPoint
162 162
      */
163
-    protected function setupRequest(){
163
+    protected function setupRequest() {
164 164
         $this->Request = new POST();
165 165
     }
166 166
 
167 167
     /**
168 168
      * Setup the Response Object Property, not called until after Request Execution
169 169
      */
170
-    protected function setupResponse(){
171
-        $this->Response = new JSONResponse($this->Request->getResponse(),$this->Request->getCurlObject());
170
+    protected function setupResponse() {
171
+        $this->Response = new JSONResponse($this->Request->getResponse(), $this->Request->getCurlObject());
172 172
     }
173 173
 
174 174
     /**
@@ -176,20 +176,20 @@  discard block
 block discarded – undo
176 176
      * @return bool
177 177
      * @throws EntryPointExecutionFailure
178 178
      */
179
-    protected function verifyURL(){
180
-        $urlVarCount = substr_count($this->_URL,"$");
179
+    protected function verifyURL() {
180
+        $urlVarCount = substr_count($this->_URL, "$");
181 181
         $optionCount = 0;
182
-        if (!empty($this->Module)){
182
+        if (!empty($this->Module)) {
183 183
             $optionCount++;
184 184
         }
185 185
         $optionCount += count($this->Options);
186
-        if ($urlVarCount!==$optionCount){
187
-            if (empty($this->Module) && strpos($this->_URL,'$module')){
186
+        if ($urlVarCount!==$optionCount) {
187
+            if (empty($this->Module) && strpos($this->_URL, '$module')) {
188 188
                 throw new EntryPointException('Module is required for EntryPoint '.get_called_class());
189
-            }else{
189
+            }else {
190 190
                 throw new EntryPointException('EntryPoint URL ('.$this->_URL.') requires more parameters than passed.');
191 191
             }
192
-        }else{
192
+        }else {
193 193
             return true;
194 194
         }
195 195
     }
@@ -197,21 +197,21 @@  discard block
 block discarded – undo
197 197
     /**
198 198
      * @return bool
199 199
      */
200
-    protected function validateData(){
201
-        if (empty($this->_REQUIRED_DATA)||count($this->_REQUIRED_DATA)==0){
200
+    protected function validateData() {
201
+        if (empty($this->_REQUIRED_DATA) || count($this->_REQUIRED_DATA)==0) {
202 202
             return true;
203
-        }else{
203
+        }else {
204 204
             $errors = array();
205
-            foreach($this->_REQUIRED_DATA as $property){
206
-                if (isset($this->Data[$property]) || $this->Data[$property]!==null){
205
+            foreach ($this->_REQUIRED_DATA as $property) {
206
+                if (isset($this->Data[$property]) || $this->Data[$property]!==null) {
207 207
                     continue;
208
-                }else{
208
+                }else {
209 209
                     $errors[] = $property;
210 210
                 }
211 211
             }
212
-            if (count($errors)>0){
213
-                throw new EntryPointException('EntryPoint requires specific properties in Request data. Missing the following '.implode($errors,","));
214
-            }else{
212
+            if (count($errors)>0) {
213
+                throw new EntryPointException('EntryPoint requires specific properties in Request data. Missing the following '.implode($errors, ","));
214
+            }else {
215 215
                 return true;
216 216
             }
217 217
         }
Please login to merge, or discard this patch.
src/EntryPoint/Abstracts/GET/FileEntryPoint.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,10 +14,10 @@
 block discarded – undo
14 14
         $this->Request = new GETFile();
15 15
     }
16 16
     protected function setupResponse() {
17
-        $this->Response = new FileResponse($this->Request->getResponse(),$this->Request->getCurlObject(),$this->downloadDir);
17
+        $this->Response = new FileResponse($this->Request->getResponse(), $this->Request->getCurlObject(), $this->downloadDir);
18 18
     }
19 19
 
20
-    public function downloadTo($path){
20
+    public function downloadTo($path) {
21 21
         $this->downloadDir = $path;
22 22
         return $this;
23 23
     }
Please login to merge, or discard this patch.
src/EntryPoint/Abstracts/GET/JSONEntryPoint.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
     /**
10 10
      * @inheritdoc
11 11
      */
12
-    protected function setupRequest(){
12
+    protected function setupRequest() {
13 13
         $this->Request = new GET();
14 14
     }
15 15
 
Please login to merge, or discard this patch.
src/EntryPoint/POST/RefreshToken.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
         'platform'
18 18
     );
19 19
 
20
-    public function data(array $data){
20
+    public function data(array $data) {
21 21
         $data['grant_type'] = 'password';
22 22
         return parent::data($data);
23 23
     }
Please login to merge, or discard this patch.
src/EntryPoint/POST/Oauth2Token.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
         'platform'
18 18
     );
19 19
 
20
-    public function data(array $data){
20
+    public function data(array $data) {
21 21
         $data['grant_type'] = 'password';
22 22
         return parent::data($data);
23 23
     }
Please login to merge, or discard this patch.
src/EntryPoint/POST/CreateRecord.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 
5 5
 use SugarAPI\SDK\EntryPoint\Abstracts\POST\JSONEntryPoint as POSTEntryPoint;
6 6
 
7
-class CreateRecord extends POSTEntryPoint{
7
+class CreateRecord extends POSTEntryPoint {
8 8
 
9 9
     protected $_URL = '$module';
10 10
 
Please login to merge, or discard this patch.
src/Response/JSON.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
     /**
11 11
      * Get JSON Response
12 12
      */
13
-    public function json(){
13
+    public function json() {
14 14
         return $this->body;
15 15
     }
16 16
 
Please login to merge, or discard this patch.
src/Response/Abstracts/AbstractResponse.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 use SugarAPI\SDK\Response\Interfaces\ResponseInterface;
6 6
 
7
-abstract class AbstractResponse implements ResponseInterface{
7
+abstract class AbstractResponse implements ResponseInterface {
8 8
 
9 9
     protected $CurlResponse;
10 10
     protected $headers;
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     protected $status;
13 13
     protected $error;
14 14
 
15
-    public function __construct($curlResponse,$curlRequest){
15
+    public function __construct($curlResponse, $curlRequest) {
16 16
         $this->CurlResponse = $curlResponse;
17 17
         if ($this->checkErrors($curlRequest)) {
18 18
             $this->extractResponse($curlRequest);
@@ -20,18 +20,18 @@  discard block
 block discarded – undo
20 20
         }
21 21
     }
22 22
 
23
-    protected function setStatus($curlRequest){
24
-        $this->status = curl_getinfo($curlRequest,CURLINFO_HTTP_CODE);
23
+    protected function setStatus($curlRequest) {
24
+        $this->status = curl_getinfo($curlRequest, CURLINFO_HTTP_CODE);
25 25
     }
26 26
 
27
-    protected function extractResponse($curlRequest){
28
-        $header_size = curl_getinfo($curlRequest,CURLINFO_HEADER_SIZE);
27
+    protected function extractResponse($curlRequest) {
28
+        $header_size = curl_getinfo($curlRequest, CURLINFO_HEADER_SIZE);
29 29
         $this->headers = substr($this->CurlResponse, 0, $header_size);
30 30
         $this->body = substr($this->CurlResponse, $header_size);
31 31
     }
32 32
 
33
-    protected function checkErrors($curlRequest){
34
-        if (curl_errno($curlRequest) !== CURLE_OK) {
33
+    protected function checkErrors($curlRequest) {
34
+        if (curl_errno($curlRequest)!==CURLE_OK) {
35 35
             $this->error = curl_error($curlRequest);
36 36
             return false;
37 37
         }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     /**
42 42
      * @inheritdoc
43 43
      */
44
-    public function getStatus(){
44
+    public function getStatus() {
45 45
         return $this->status;
46 46
     }
47 47
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     /**
63 63
      * @inheritdoc
64 64
      */
65
-    public function getError(){
65
+    public function getError() {
66 66
         return $this->error;
67 67
     }
68 68
 
Please login to merge, or discard this patch.
src/Response/File.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
      */
18 18
     protected $destinationPath;
19 19
 
20
-    public function __construct($curlResponse, $curlRequest,$destination = null) {
20
+    public function __construct($curlResponse, $curlRequest, $destination = null) {
21 21
         parent::__construct($curlResponse, $curlRequest);
22 22
         $this->extractFileName();
23 23
         if (!empty($destination)) {
@@ -26,37 +26,37 @@  discard block
 block discarded – undo
26 26
         }
27 27
     }
28 28
 
29
-    protected function setupDestiantion($destination = null){
30
-        if (empty($destination)){
29
+    protected function setupDestiantion($destination = null) {
30
+        if (empty($destination)) {
31 31
             $destination = sys_get_temp_dir().'/SugarAPI';
32
-            if (!file_exists($destination)){
33
-                mkdir($destination,0777);
32
+            if (!file_exists($destination)) {
33
+                mkdir($destination, 0777);
34 34
             }
35 35
         }
36 36
         $this->destinationPath = $destination;
37 37
     }
38 38
 
39
-    protected function extractFileName(){
40
-        foreach (explode("\r\n",$this->headers) as $header)
39
+    protected function extractFileName() {
40
+        foreach (explode("\r\n", $this->headers) as $header)
41 41
         {
42
-            if (strpos($header,'filename')!==FALSE){
43
-                $this->fileName = substr($header,(strpos($header,"\"")+1),-1);
42
+            if (strpos($header, 'filename')!==FALSE) {
43
+                $this->fileName = substr($header, (strpos($header, "\"") + 1), -1);
44 44
             }
45 45
         }
46 46
     }
47 47
 
48
-    public function getFileName(){
48
+    public function getFileName() {
49 49
         return $this->fileName;
50 50
     }
51 51
 
52
-    protected function writeFile(){
53
-        $fileHandle = fopen($this->file(),'w+');
54
-        fwrite($fileHandle,$this->body);
52
+    protected function writeFile() {
53
+        $fileHandle = fopen($this->file(), 'w+');
54
+        fwrite($fileHandle, $this->body);
55 55
         fclose($fileHandle);
56 56
     }
57 57
 
58
-    public function file(){
59
-        return rtrim($this->destinationPath,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$this->fileName;
58
+    public function file() {
59
+        return rtrim($this->destinationPath, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$this->fileName;
60 60
     }
61 61
 
62 62
 }
63 63
\ No newline at end of file
Please login to merge, or discard this patch.