@@ -16,9 +16,9 @@ |
||
| 16 | 16 | * Overrides POST setBody, so that Body is not json encoded |
| 17 | 17 | * @inheritdoc |
| 18 | 18 | */ |
| 19 | - public function setBody(array $body) { |
|
| 19 | + public function setBody(array $body){ |
|
| 20 | 20 | $this->body = $body; |
| 21 | - $this->setOption(CURLOPT_POSTFIELDS,$this->body); |
|
| 21 | + $this->setOption(CURLOPT_POSTFIELDS, $this->body); |
|
| 22 | 22 | return $this; |
| 23 | 23 | } |
| 24 | 24 | |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | * Overrides POST setBody, so that Body is not json encoded |
| 17 | 17 | * @inheritdoc |
| 18 | 18 | */ |
| 19 | - public function setBody(array $body) { |
|
| 19 | + public function setBody(array $body){ |
|
| 20 | 20 | $this->body = $body; |
| 21 | 21 | $this->setOption(CURLOPT_POSTFIELDS,$this->body); |
| 22 | 22 | return $this; |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use SugarAPI\SDK\Request\Abstracts\AbstractRequest; |
| 6 | 6 | |
| 7 | -class POST extends AbstractRequest{ |
|
| 7 | +class POST extends AbstractRequest { |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * @inheritdoc |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * JSON Encode Body |
| 33 | 33 | * @inheritdoc |
| 34 | 34 | */ |
| 35 | - public function setBody($body) { |
|
| 35 | + public function setBody($body){ |
|
| 36 | 36 | return parent::setBody(json_encode($body)); |
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use SugarAPI\SDK\Request\Abstracts\AbstractRequest; |
| 6 | 6 | |
| 7 | -class POST extends AbstractRequest{ |
|
| 7 | +class POST extends AbstractRequest { |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * @inheritdoc |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * JSON Encode Body |
| 33 | 33 | * @inheritdoc |
| 34 | 34 | */ |
| 35 | - public function setBody($body) { |
|
| 35 | + public function setBody($body){ |
|
| 36 | 36 | return parent::setBody(json_encode($body)); |
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use SugarAPI\SDK\Request\Interfaces\RequestInterface; |
| 6 | 6 | |
| 7 | -abstract class AbstractRequest implements RequestInterface{ |
|
| 7 | +abstract class AbstractRequest implements RequestInterface { |
|
| 8 | 8 | |
| 9 | 9 | const STATUS_INIT = 'initialized'; |
| 10 | 10 | const STATUS_SENT = 'sent'; |
@@ -81,31 +81,31 @@ discard block |
||
| 81 | 81 | $this->setURL($url); |
| 82 | 82 | } |
| 83 | 83 | $this->setType(); |
| 84 | - foreach(static::$_DEFAULT_OPTIONS as $option => $value){ |
|
| 85 | - $this->setOption($option,$value); |
|
| 84 | + foreach (static::$_DEFAULT_OPTIONS as $option => $value){ |
|
| 85 | + $this->setOption($option, $value); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * @inheritdoc |
| 91 | 91 | */ |
| 92 | - public function setURL($url) { |
|
| 92 | + public function setURL($url){ |
|
| 93 | 93 | $this->url = $url; |
| 94 | - $this->setOption(CURLOPT_URL,$this->url); |
|
| 94 | + $this->setOption(CURLOPT_URL, $this->url); |
|
| 95 | 95 | return $this; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * @inheritdoc |
| 100 | 100 | */ |
| 101 | - public function getURL() { |
|
| 101 | + public function getURL(){ |
|
| 102 | 102 | return $this->url; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * @inheritdoc |
| 107 | 107 | */ |
| 108 | - public function addHeader($name, $value) { |
|
| 108 | + public function addHeader($name, $value){ |
|
| 109 | 109 | $token = $name.": ".$value; |
| 110 | 110 | $this->headers[] = $token; |
| 111 | 111 | return $this; |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | /** |
| 115 | 115 | * @inheritdoc |
| 116 | 116 | */ |
| 117 | - public function setHeaders(array $array = array()) { |
|
| 118 | - if (count($array)>0) { |
|
| 119 | - foreach ($array as $key => $value) { |
|
| 117 | + public function setHeaders(array $array = array()){ |
|
| 118 | + if (count($array)>0){ |
|
| 119 | + foreach ($array as $key => $value){ |
|
| 120 | 120 | $this->addHeader($key, $value); |
| 121 | 121 | } |
| 122 | 122 | } |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | /** |
| 128 | 128 | * @inheritdoc |
| 129 | 129 | */ |
| 130 | - public function getHeaders() { |
|
| 130 | + public function getHeaders(){ |
|
| 131 | 131 | return $this->headers; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | 135 | * @inheritdoc |
| 136 | 136 | */ |
| 137 | - public function setBody(array $body) { |
|
| 137 | + public function setBody(array $body){ |
|
| 138 | 138 | $this->body = $body; |
| 139 | 139 | $this->setOption(CURLOPT_POSTFIELDS, $this->body); |
| 140 | 140 | return $this; |
@@ -143,28 +143,28 @@ discard block |
||
| 143 | 143 | /** |
| 144 | 144 | * @inheritdoc |
| 145 | 145 | */ |
| 146 | - public function getBody() { |
|
| 146 | + public function getBody(){ |
|
| 147 | 147 | return $this->body; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | 151 | * @inheritdoc |
| 152 | 152 | */ |
| 153 | - public function getCurlObject() { |
|
| 153 | + public function getCurlObject(){ |
|
| 154 | 154 | return $this->CurlRequest; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
| 158 | 158 | * @inheritdoc |
| 159 | 159 | */ |
| 160 | - public function setOption($option, $value) { |
|
| 160 | + public function setOption($option, $value){ |
|
| 161 | 161 | curl_setopt($this->CurlRequest, $option, $value); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | 165 | * @inheritdoc |
| 166 | 166 | */ |
| 167 | - public function send() { |
|
| 167 | + public function send(){ |
|
| 168 | 168 | $this->setHeaders(); |
| 169 | 169 | $this->CurlResponse = curl_exec($this->CurlRequest); |
| 170 | 170 | $this->status = self::STATUS_SENT; |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | /** |
| 200 | 200 | * @inheritdoc |
| 201 | 201 | */ |
| 202 | - public function start() { |
|
| 202 | + public function start(){ |
|
| 203 | 203 | $this->CurlRequest = curl_init(); |
| 204 | 204 | $this->status = self::STATUS_INIT; |
| 205 | 205 | return $this; |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | /** |
| 219 | 219 | * @inheritdoc |
| 220 | 220 | */ |
| 221 | - public function getCurlStatus() { |
|
| 221 | + public function getCurlStatus(){ |
|
| 222 | 222 | return $this->status; |
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use SugarAPI\SDK\Request\Interfaces\RequestInterface; |
| 6 | 6 | |
| 7 | -abstract class AbstractRequest implements RequestInterface{ |
|
| 7 | +abstract class AbstractRequest implements RequestInterface { |
|
| 8 | 8 | |
| 9 | 9 | const STATUS_INIT = 'initialized'; |
| 10 | 10 | const STATUS_SENT = 'sent'; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | /** |
| 90 | 90 | * @inheritdoc |
| 91 | 91 | */ |
| 92 | - public function setURL($url) { |
|
| 92 | + public function setURL($url){ |
|
| 93 | 93 | $this->url = $url; |
| 94 | 94 | $this->setOption(CURLOPT_URL,$this->url); |
| 95 | 95 | return $this; |
@@ -98,14 +98,14 @@ discard block |
||
| 98 | 98 | /** |
| 99 | 99 | * @inheritdoc |
| 100 | 100 | */ |
| 101 | - public function getURL() { |
|
| 101 | + public function getURL(){ |
|
| 102 | 102 | return $this->url; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * @inheritdoc |
| 107 | 107 | */ |
| 108 | - public function addHeader($name, $value) { |
|
| 108 | + public function addHeader($name, $value){ |
|
| 109 | 109 | $token = $name.": ".$value; |
| 110 | 110 | $this->headers[] = $token; |
| 111 | 111 | return $this; |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | /** |
| 115 | 115 | * @inheritdoc |
| 116 | 116 | */ |
| 117 | - public function setHeaders(array $array = array()) { |
|
| 118 | - if (count($array)>0) { |
|
| 119 | - foreach ($array as $key => $value) { |
|
| 117 | + public function setHeaders(array $array = array()){ |
|
| 118 | + if (count($array)>0){ |
|
| 119 | + foreach ($array as $key => $value){ |
|
| 120 | 120 | $this->addHeader($key, $value); |
| 121 | 121 | } |
| 122 | 122 | } |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | /** |
| 128 | 128 | * @inheritdoc |
| 129 | 129 | */ |
| 130 | - public function getHeaders() { |
|
| 130 | + public function getHeaders(){ |
|
| 131 | 131 | return $this->headers; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | 135 | * @inheritdoc |
| 136 | 136 | */ |
| 137 | - public function setBody(array $body) { |
|
| 137 | + public function setBody(array $body){ |
|
| 138 | 138 | $this->body = $body; |
| 139 | 139 | $this->setOption(CURLOPT_POSTFIELDS, $this->body); |
| 140 | 140 | return $this; |
@@ -143,28 +143,28 @@ discard block |
||
| 143 | 143 | /** |
| 144 | 144 | * @inheritdoc |
| 145 | 145 | */ |
| 146 | - public function getBody() { |
|
| 146 | + public function getBody(){ |
|
| 147 | 147 | return $this->body; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | 151 | * @inheritdoc |
| 152 | 152 | */ |
| 153 | - public function getCurlObject() { |
|
| 153 | + public function getCurlObject(){ |
|
| 154 | 154 | return $this->CurlRequest; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
| 158 | 158 | * @inheritdoc |
| 159 | 159 | */ |
| 160 | - public function setOption($option, $value) { |
|
| 160 | + public function setOption($option, $value){ |
|
| 161 | 161 | curl_setopt($this->CurlRequest, $option, $value); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | 165 | * @inheritdoc |
| 166 | 166 | */ |
| 167 | - public function send() { |
|
| 167 | + public function send(){ |
|
| 168 | 168 | $this->setHeaders(); |
| 169 | 169 | $this->CurlResponse = curl_exec($this->CurlRequest); |
| 170 | 170 | $this->status = self::STATUS_SENT; |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | /** |
| 200 | 200 | * @inheritdoc |
| 201 | 201 | */ |
| 202 | - public function start() { |
|
| 202 | + public function start(){ |
|
| 203 | 203 | $this->CurlRequest = curl_init(); |
| 204 | 204 | $this->status = self::STATUS_INIT; |
| 205 | 205 | return $this; |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | /** |
| 219 | 219 | * @inheritdoc |
| 220 | 220 | */ |
| 221 | - public function getCurlStatus() { |
|
| 221 | + public function getCurlStatus(){ |
|
| 222 | 222 | return $this->status; |
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | protected static $_DEFAULT_OPTIONS = array( |
| 24 | 24 | CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_0, |
| 25 | - CURLOPT_HEADER => true, |
|
| 25 | + CURLOPT_HEADER => TRUE, |
|
| 26 | 26 | CURLOPT_SSL_VERIFYPEER => 0, |
| 27 | 27 | CURLOPT_RETURNTRANSFER => 1, |
| 28 | 28 | CURLOPT_FOLLOWLOCATION => 0 |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | /** |
| 68 | 68 | * @var null |
| 69 | 69 | */ |
| 70 | - protected $status = null; |
|
| 70 | + protected $status = NULL; |
|
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * The Request Type |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | protected $type; |
| 77 | 77 | |
| 78 | - public function __construct($url = null){ |
|
| 78 | + public function __construct($url = NULL){ |
|
| 79 | 79 | $this->start(); |
| 80 | 80 | if (!empty($url)){ |
| 81 | 81 | $this->setURL($url); |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use SugarAPI\SDK\Request\Abstracts\AbstractRequest; |
| 6 | 6 | |
| 7 | -class PUT extends AbstractRequest{ |
|
| 7 | +class PUT extends AbstractRequest { |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * @inheritdoc |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * JSON Encode Body |
| 33 | 33 | * @inheritdoc |
| 34 | 34 | */ |
| 35 | - public function setBody(array $body) { |
|
| 35 | + public function setBody(array $body){ |
|
| 36 | 36 | return parent::setBody(json_encode($body)); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use SugarAPI\SDK\Request\Abstracts\AbstractRequest; |
| 6 | 6 | |
| 7 | -class PUT extends AbstractRequest{ |
|
| 7 | +class PUT extends AbstractRequest { |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * @inheritdoc |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * JSON Encode Body |
| 33 | 33 | * @inheritdoc |
| 34 | 34 | */ |
| 35 | - public function setBody(array $body) { |
|
| 35 | + public function setBody(array $body){ |
|
| 36 | 36 | return parent::setBody(json_encode($body)); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use SugarAPI\SDK\Request\Abstracts\AbstractRequest; |
| 6 | 6 | |
| 7 | -class DELETE extends AbstractRequest{ |
|
| 7 | +class DELETE extends AbstractRequest { |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * @inheritdoc |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * JSON Encode Body |
| 33 | 33 | * @inheritdoc |
| 34 | 34 | */ |
| 35 | - public function setBody(array $body) { |
|
| 35 | + public function setBody(array $body){ |
|
| 36 | 36 | return parent::setBody(json_encode($body)); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use SugarAPI\SDK\Request\Abstracts\AbstractRequest; |
| 6 | 6 | |
| 7 | -class DELETE extends AbstractRequest{ |
|
| 7 | +class DELETE extends AbstractRequest { |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * @inheritdoc |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * JSON Encode Body |
| 33 | 33 | * @inheritdoc |
| 34 | 34 | */ |
| 35 | - public function setBody(array $body) { |
|
| 35 | + public function setBody(array $body){ |
|
| 36 | 36 | return parent::setBody(json_encode($body)); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -4,7 +4,7 @@ discard block |
||
| 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 | /** |
| 10 | 10 | * Full Curl Response |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | protected $error; |
| 38 | 38 | |
| 39 | - public function __construct($curlResponse,$curlRequest){ |
|
| 39 | + public function __construct($curlResponse, $curlRequest){ |
|
| 40 | 40 | $this->CurlResponse = $curlResponse; |
| 41 | - if ($this->checkErrors($curlRequest)) { |
|
| 41 | + if ($this->checkErrors($curlRequest)){ |
|
| 42 | 42 | $this->extractResponse($curlRequest); |
| 43 | 43 | } |
| 44 | 44 | $this->setStatus($curlRequest); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @param $curlRequest - Curl resource |
| 50 | 50 | */ |
| 51 | 51 | protected function setStatus($curlRequest){ |
| 52 | - $this->status = curl_getinfo($curlRequest,CURLINFO_HTTP_CODE); |
|
| 52 | + $this->status = curl_getinfo($curlRequest, CURLINFO_HTTP_CODE); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @param $curlRequest |
| 58 | 58 | */ |
| 59 | 59 | protected function extractResponse($curlRequest){ |
| 60 | - $header_size = curl_getinfo($curlRequest,CURLINFO_HEADER_SIZE); |
|
| 60 | + $header_size = curl_getinfo($curlRequest, CURLINFO_HEADER_SIZE); |
|
| 61 | 61 | $this->headers = substr($this->CurlResponse, 0, $header_size); |
| 62 | 62 | $this->body = substr($this->CurlResponse, $header_size); |
| 63 | 63 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return bool |
| 69 | 69 | */ |
| 70 | 70 | protected function checkErrors($curlRequest){ |
| 71 | - if (curl_errno($curlRequest) !== CURLE_OK) { |
|
| 71 | + if (curl_errno($curlRequest)!==CURLE_OK){ |
|
| 72 | 72 | $this->error = curl_error($curlRequest); |
| 73 | 73 | return false; |
| 74 | 74 | } |
@@ -85,14 +85,14 @@ discard block |
||
| 85 | 85 | /** |
| 86 | 86 | * @inheritdoc |
| 87 | 87 | */ |
| 88 | - public function getBody() { |
|
| 88 | + public function getBody(){ |
|
| 89 | 89 | return $this->body; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * @inheritdoc |
| 94 | 94 | */ |
| 95 | - public function getHeaders() { |
|
| 95 | + public function getHeaders(){ |
|
| 96 | 96 | return $this->headers; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -4,7 +4,7 @@ discard block |
||
| 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 | /** |
| 10 | 10 | * Full Curl Response |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | public function __construct($curlResponse,$curlRequest){ |
| 40 | 40 | $this->CurlResponse = $curlResponse; |
| 41 | - if ($this->checkErrors($curlRequest)) { |
|
| 41 | + if ($this->checkErrors($curlRequest)){ |
|
| 42 | 42 | $this->extractResponse($curlRequest); |
| 43 | 43 | } |
| 44 | 44 | $this->setStatus($curlRequest); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return bool |
| 69 | 69 | */ |
| 70 | 70 | protected function checkErrors($curlRequest){ |
| 71 | - if (curl_errno($curlRequest) !== CURLE_OK) { |
|
| 71 | + if (curl_errno($curlRequest) !== CURLE_OK){ |
|
| 72 | 72 | $this->error = curl_error($curlRequest); |
| 73 | 73 | return false; |
| 74 | 74 | } |
@@ -85,14 +85,14 @@ discard block |
||
| 85 | 85 | /** |
| 86 | 86 | * @inheritdoc |
| 87 | 87 | */ |
| 88 | - public function getBody() { |
|
| 88 | + public function getBody(){ |
|
| 89 | 89 | return $this->body; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * @inheritdoc |
| 94 | 94 | */ |
| 95 | - public function getHeaders() { |
|
| 95 | + public function getHeaders(){ |
|
| 96 | 96 | return $this->headers; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -70,9 +70,9 @@ |
||
| 70 | 70 | protected function checkErrors($curlRequest){ |
| 71 | 71 | if (curl_errno($curlRequest) !== CURLE_OK) { |
| 72 | 72 | $this->error = curl_error($curlRequest); |
| 73 | - return false; |
|
| 73 | + return FALSE; |
|
| 74 | 74 | } |
| 75 | - return true; |
|
| 75 | + return TRUE; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -18,10 +18,10 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | protected $destinationPath; |
| 20 | 20 | |
| 21 | - public function __construct($curlResponse, $curlRequest,$destination = null) { |
|
| 21 | + public function __construct($curlResponse, $curlRequest, $destination = null){ |
|
| 22 | 22 | parent::__construct($curlResponse, $curlRequest); |
| 23 | 23 | $this->extractFileName(); |
| 24 | - if (!empty($destination)) { |
|
| 24 | + if (!empty($destination)){ |
|
| 25 | 25 | $this->setupDestination($destination); |
| 26 | 26 | $this->writeFile(); |
| 27 | 27 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | if (empty($destination)){ |
| 36 | 36 | $destination = sys_get_temp_dir().'/SugarAPI'; |
| 37 | 37 | if (!file_exists($destination)){ |
| 38 | - mkdir($destination,0777); |
|
| 38 | + mkdir($destination, 0777); |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | $this->destinationPath = $destination; |
@@ -45,10 +45,10 @@ discard block |
||
| 45 | 45 | * Extract the filename from the Headers, and store it in filename property |
| 46 | 46 | */ |
| 47 | 47 | protected function extractFileName(){ |
| 48 | - foreach (explode("\r\n",$this->headers) as $header) |
|
| 48 | + foreach (explode("\r\n", $this->headers) as $header) |
|
| 49 | 49 | { |
| 50 | - if (strpos($header,'filename')!==FALSE){ |
|
| 51 | - $this->fileName = substr($header,(strpos($header,"\"")+1),-1); |
|
| 50 | + if (strpos($header, 'filename')!==FALSE){ |
|
| 51 | + $this->fileName = substr($header, (strpos($header, "\"")+1), -1); |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | * Write the downloaded file |
| 66 | 66 | */ |
| 67 | 67 | protected function writeFile(){ |
| 68 | - $fileHandle = fopen($this->file(),'w+'); |
|
| 69 | - fwrite($fileHandle,$this->body); |
|
| 68 | + $fileHandle = fopen($this->file(), 'w+'); |
|
| 69 | + fwrite($fileHandle, $this->body); |
|
| 70 | 70 | fclose($fileHandle); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @return string |
| 76 | 76 | */ |
| 77 | 77 | public function file(){ |
| 78 | - return rtrim($this->destinationPath,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$this->fileName; |
|
| 78 | + return rtrim($this->destinationPath, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$this->fileName; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | } |
| 82 | 82 | \ No newline at end of file |
@@ -18,10 +18,10 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | protected $destinationPath; |
| 20 | 20 | |
| 21 | - public function __construct($curlResponse, $curlRequest,$destination = null) { |
|
| 21 | + public function __construct($curlResponse, $curlRequest,$destination = null){ |
|
| 22 | 22 | parent::__construct($curlResponse, $curlRequest); |
| 23 | 23 | $this->extractFileName(); |
| 24 | - if (!empty($destination)) { |
|
| 24 | + if (!empty($destination)){ |
|
| 25 | 25 | $this->setupDestination($destination); |
| 26 | 26 | $this->writeFile(); |
| 27 | 27 | } |
@@ -45,8 +45,7 @@ discard block |
||
| 45 | 45 | * Extract the filename from the Headers, and store it in filename property |
| 46 | 46 | */ |
| 47 | 47 | protected function extractFileName(){ |
| 48 | - foreach (explode("\r\n",$this->headers) as $header) |
|
| 49 | - { |
|
| 48 | + foreach (explode("\r\n",$this->headers) as $header){ |
|
| 50 | 49 | if (strpos($header,'filename')!==FALSE){ |
| 51 | 50 | $this->fileName = substr($header,(strpos($header,"\"")+1),-1); |
| 52 | 51 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | protected $destinationPath; |
| 20 | 20 | |
| 21 | - public function __construct($curlResponse, $curlRequest,$destination = null) { |
|
| 21 | + public function __construct($curlResponse, $curlRequest,$destination = NULL) { |
|
| 22 | 22 | parent::__construct($curlResponse, $curlRequest); |
| 23 | 23 | $this->extractFileName(); |
| 24 | 24 | if (!empty($destination)) { |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * Configure the Destination path to store the File response |
| 32 | 32 | * @param null $destination |
| 33 | 33 | */ |
| 34 | - protected function setupDestination($destination = null){ |
|
| 34 | + protected function setupDestination($destination = NULL){ |
|
| 35 | 35 | if (empty($destination)){ |
| 36 | 36 | $destination = sys_get_temp_dir().'/SugarAPI'; |
| 37 | 37 | if (!file_exists($destination)){ |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | protected $accessToken; |
| 87 | 87 | |
| 88 | - public function __construct($url,$options = array()){ |
|
| 88 | + public function __construct($url, $options = array()){ |
|
| 89 | 89 | $this->url = $url; |
| 90 | 90 | $this->Module = $this->_MODULE; |
| 91 | 91 | |
| 92 | - if (!empty($options)) { |
|
| 93 | - if (empty($this->Module)) { |
|
| 94 | - if (strpos($this->_URL, '$module') !== FALSE) { |
|
| 92 | + if (!empty($options)){ |
|
| 93 | + if (empty($this->Module)){ |
|
| 94 | + if (strpos($this->_URL, '$module')!==FALSE){ |
|
| 95 | 95 | $this->module($options[0]); |
| 96 | 96 | array_shift($options); |
| 97 | 97 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @inheritdoc |
| 131 | 131 | */ |
| 132 | 132 | public function execute(){ |
| 133 | - if ($this->verifyURL() && $this->validateData()) { |
|
| 133 | + if ($this->verifyURL() && $this->validateData()){ |
|
| 134 | 134 | $this->configureURL(); |
| 135 | 135 | $this->Request->setURL($this->url); |
| 136 | 136 | $this->Request->send(); |
@@ -144,14 +144,14 @@ discard block |
||
| 144 | 144 | /** |
| 145 | 145 | * @inheritdoc |
| 146 | 146 | */ |
| 147 | - public function authRequired() { |
|
| 147 | + public function authRequired(){ |
|
| 148 | 148 | return $this->_AUTH_REQUIRED; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | 152 | * @inheritdoc |
| 153 | 153 | */ |
| 154 | - public function configureAuth($accessToken) { |
|
| 154 | + public function configureAuth($accessToken){ |
|
| 155 | 155 | if ($this->authRequired()){ |
| 156 | 156 | $this->accessToken = $accessToken; |
| 157 | 157 | $this->Request->addHeader('OAuth-Token', $accessToken); |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | /** |
| 163 | 163 | * @inheritdoc |
| 164 | 164 | */ |
| 165 | - public function getModule() { |
|
| 165 | + public function getModule(){ |
|
| 166 | 166 | return $this->Module; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -201,30 +201,30 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | protected function configureURL(){ |
| 203 | 203 | $url = $this->_URL; |
| 204 | - if (strpos($this->_URL,"$")!==FALSE) { |
|
| 205 | - if (count($this->Options) > 0 || !empty($this->Module)) { |
|
| 204 | + if (strpos($this->_URL, "$")!==FALSE){ |
|
| 205 | + if (count($this->Options)>0 || !empty($this->Module)){ |
|
| 206 | 206 | $urlParts = explode("/", $this->_URL); |
| 207 | 207 | $o = 0; |
| 208 | - foreach ($urlParts as $key => $part) { |
|
| 209 | - if (strpos($part, '$module') !== FALSE) { |
|
| 210 | - if (isset($this->Module)) { |
|
| 208 | + foreach ($urlParts as $key => $part){ |
|
| 209 | + if (strpos($part, '$module')!==FALSE){ |
|
| 210 | + if (isset($this->Module)){ |
|
| 211 | 211 | $urlParts[$key] = $this->Module; |
| 212 | 212 | continue; |
| 213 | - } else { |
|
| 214 | - if (isset($this->Options[$o])) { |
|
| 213 | + }else{ |
|
| 214 | + if (isset($this->Options[$o])){ |
|
| 215 | 215 | $this->Module = $this->Options[$o]; |
| 216 | 216 | array_shift($this->Options); |
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | - if (strpos($part, "$") !== FALSE) { |
|
| 221 | - if (isset($this->Options[$o])) { |
|
| 220 | + if (strpos($part, "$")!==FALSE){ |
|
| 221 | + if (isset($this->Options[$o])){ |
|
| 222 | 222 | $urlParts[$key] = $this->Options[$o]; |
| 223 | 223 | $o++; |
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | - $url = implode($urlParts,"/"); |
|
| 227 | + $url = implode($urlParts, "/"); |
|
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | $this->url = $this->url.$url; |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * Setup the Response Object Property, not called until after Request Execution |
| 242 | 242 | */ |
| 243 | 243 | protected function setupResponse(){ |
| 244 | - $this->Response = new JSONResponse($this->Request->getResponse(),$this->Request->getCurlObject()); |
|
| 244 | + $this->Response = new JSONResponse($this->Request->getResponse(), $this->Request->getCurlObject()); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | * @throws EntryPointException |
| 251 | 251 | */ |
| 252 | 252 | protected function verifyURL(){ |
| 253 | - $urlVarCount = substr_count($this->_URL,"$"); |
|
| 253 | + $urlVarCount = substr_count($this->_URL, "$"); |
|
| 254 | 254 | $optionCount = 0; |
| 255 | 255 | if (!empty($this->Module)){ |
| 256 | 256 | $optionCount++; |
| 257 | 257 | } |
| 258 | 258 | $optionCount += count($this->Options); |
| 259 | 259 | if ($urlVarCount!==$optionCount){ |
| 260 | - if (empty($this->Module) && strpos($this->_URL,'$module')){ |
|
| 260 | + if (empty($this->Module) && strpos($this->_URL, '$module')){ |
|
| 261 | 261 | throw new EntryPointException('Module is required for EntryPoint '.get_called_class()); |
| 262 | 262 | }else{ |
| 263 | 263 | throw new EntryPointException('EntryPoint URL ('.$this->_URL.') requires more parameters than passed.'); |
@@ -273,11 +273,11 @@ discard block |
||
| 273 | 273 | * @throws EntryPointException |
| 274 | 274 | */ |
| 275 | 275 | protected function validateData(){ |
| 276 | - if (empty($this->_REQUIRED_DATA)||count($this->_REQUIRED_DATA)==0){ |
|
| 276 | + if (empty($this->_REQUIRED_DATA) || count($this->_REQUIRED_DATA)==0){ |
|
| 277 | 277 | return true; |
| 278 | 278 | }else{ |
| 279 | 279 | $errors = array(); |
| 280 | - foreach($this->_REQUIRED_DATA as $property){ |
|
| 280 | + foreach ($this->_REQUIRED_DATA as $property){ |
|
| 281 | 281 | if (isset($this->Data[$property]) || $this->Data[$property]!==null){ |
| 282 | 282 | continue; |
| 283 | 283 | }else{ |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | if (count($errors)>0){ |
| 288 | - throw new EntryPointException('EntryPoint requires specific properties in Request data. Missing the following '.implode($errors,",")); |
|
| 288 | + throw new EntryPointException('EntryPoint requires specific properties in Request data. Missing the following '.implode($errors, ",")); |
|
| 289 | 289 | }else{ |
| 290 | 290 | return true; |
| 291 | 291 | } |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | $this->url = $url; |
| 90 | 90 | $this->Module = $this->_MODULE; |
| 91 | 91 | |
| 92 | - if (!empty($options)) { |
|
| 93 | - if (empty($this->Module)) { |
|
| 94 | - if (strpos($this->_URL, '$module') !== FALSE) { |
|
| 92 | + if (!empty($options)){ |
|
| 93 | + if (empty($this->Module)){ |
|
| 94 | + if (strpos($this->_URL, '$module') !== FALSE){ |
|
| 95 | 95 | $this->module($options[0]); |
| 96 | 96 | array_shift($options); |
| 97 | 97 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @inheritdoc |
| 131 | 131 | */ |
| 132 | 132 | public function execute(){ |
| 133 | - if ($this->verifyURL() && $this->validateData()) { |
|
| 133 | + if ($this->verifyURL() && $this->validateData()){ |
|
| 134 | 134 | $this->configureURL(); |
| 135 | 135 | $this->Request->setURL($this->url); |
| 136 | 136 | $this->Request->send(); |
@@ -144,14 +144,14 @@ discard block |
||
| 144 | 144 | /** |
| 145 | 145 | * @inheritdoc |
| 146 | 146 | */ |
| 147 | - public function authRequired() { |
|
| 147 | + public function authRequired(){ |
|
| 148 | 148 | return $this->_AUTH_REQUIRED; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | 152 | * @inheritdoc |
| 153 | 153 | */ |
| 154 | - public function configureAuth($accessToken) { |
|
| 154 | + public function configureAuth($accessToken){ |
|
| 155 | 155 | if ($this->authRequired()){ |
| 156 | 156 | $this->accessToken = $accessToken; |
| 157 | 157 | $this->Request->addHeader('OAuth-Token', $accessToken); |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | /** |
| 163 | 163 | * @inheritdoc |
| 164 | 164 | */ |
| 165 | - public function getModule() { |
|
| 165 | + public function getModule(){ |
|
| 166 | 166 | return $this->Module; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -201,24 +201,24 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | protected function configureURL(){ |
| 203 | 203 | $url = $this->_URL; |
| 204 | - if (strpos($this->_URL,"$")!==FALSE) { |
|
| 205 | - if (count($this->Options) > 0 || !empty($this->Module)) { |
|
| 204 | + if (strpos($this->_URL,"$")!==FALSE){ |
|
| 205 | + if (count($this->Options) > 0 || !empty($this->Module)){ |
|
| 206 | 206 | $urlParts = explode("/", $this->_URL); |
| 207 | 207 | $o = 0; |
| 208 | - foreach ($urlParts as $key => $part) { |
|
| 209 | - if (strpos($part, '$module') !== FALSE) { |
|
| 210 | - if (isset($this->Module)) { |
|
| 208 | + foreach ($urlParts as $key => $part){ |
|
| 209 | + if (strpos($part, '$module') !== FALSE){ |
|
| 210 | + if (isset($this->Module)){ |
|
| 211 | 211 | $urlParts[$key] = $this->Module; |
| 212 | 212 | continue; |
| 213 | - } else { |
|
| 214 | - if (isset($this->Options[$o])) { |
|
| 213 | + } else{ |
|
| 214 | + if (isset($this->Options[$o])){ |
|
| 215 | 215 | $this->Module = $this->Options[$o]; |
| 216 | 216 | array_shift($this->Options); |
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | - if (strpos($part, "$") !== FALSE) { |
|
| 221 | - if (isset($this->Options[$o])) { |
|
| 220 | + if (strpos($part, "$") !== FALSE){ |
|
| 221 | + if (isset($this->Options[$o])){ |
|
| 222 | 222 | $urlParts[$key] = $this->Options[$o]; |
| 223 | 223 | $o++; |
| 224 | 224 | } |
@@ -259,10 +259,10 @@ discard block |
||
| 259 | 259 | if ($urlVarCount!==$optionCount){ |
| 260 | 260 | if (empty($this->Module) && strpos($this->_URL,'$module')){ |
| 261 | 261 | throw new EntryPointException('Module is required for EntryPoint '.get_called_class()); |
| 262 | - }else{ |
|
| 262 | + } else{ |
|
| 263 | 263 | throw new EntryPointException('EntryPoint URL ('.$this->_URL.') requires more parameters than passed.'); |
| 264 | 264 | } |
| 265 | - }else{ |
|
| 265 | + } else{ |
|
| 266 | 266 | return true; |
| 267 | 267 | } |
| 268 | 268 | } |
@@ -275,18 +275,18 @@ discard block |
||
| 275 | 275 | protected function validateData(){ |
| 276 | 276 | if (empty($this->_REQUIRED_DATA)||count($this->_REQUIRED_DATA)==0){ |
| 277 | 277 | return true; |
| 278 | - }else{ |
|
| 278 | + } else{ |
|
| 279 | 279 | $errors = array(); |
| 280 | 280 | foreach($this->_REQUIRED_DATA as $property){ |
| 281 | 281 | if (isset($this->Data[$property]) || $this->Data[$property]!==null){ |
| 282 | 282 | continue; |
| 283 | - }else{ |
|
| 283 | + } else{ |
|
| 284 | 284 | $errors[] = $property; |
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | if (count($errors)>0){ |
| 288 | 288 | throw new EntryPointException('EntryPoint requires specific properties in Request data. Missing the following '.implode($errors,",")); |
| 289 | - }else{ |
|
| 289 | + } else{ |
|
| 290 | 290 | return true; |
| 291 | 291 | } |
| 292 | 292 | } |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * Whether or not Authentication is Required |
| 15 | 15 | * @var bool |
| 16 | 16 | */ |
| 17 | - protected $_AUTH_REQUIRED = true; |
|
| 17 | + protected $_AUTH_REQUIRED = TRUE; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * The default Module for the EntryPoint |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | throw new EntryPointException('EntryPoint URL ('.$this->_URL.') requires more parameters than passed.'); |
| 264 | 264 | } |
| 265 | 265 | }else{ |
| 266 | - return true; |
|
| 266 | + return TRUE; |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
@@ -274,11 +274,11 @@ discard block |
||
| 274 | 274 | */ |
| 275 | 275 | protected function validateData(){ |
| 276 | 276 | if (empty($this->_REQUIRED_DATA)||count($this->_REQUIRED_DATA)==0){ |
| 277 | - return true; |
|
| 277 | + return TRUE; |
|
| 278 | 278 | }else{ |
| 279 | 279 | $errors = array(); |
| 280 | 280 | foreach($this->_REQUIRED_DATA as $property){ |
| 281 | - if (isset($this->Data[$property]) || $this->Data[$property]!==null){ |
|
| 281 | + if (isset($this->Data[$property]) || $this->Data[$property]!==NULL){ |
|
| 282 | 282 | continue; |
| 283 | 283 | }else{ |
| 284 | 284 | $errors[] = $property; |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | if (count($errors)>0){ |
| 288 | 288 | throw new EntryPointException('EntryPoint requires specific properties in Request data. Missing the following '.implode($errors,",")); |
| 289 | 289 | }else{ |
| 290 | - return true; |
|
| 290 | + return TRUE; |
|
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | 293 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * @inheritdoc |
| 19 | 19 | */ |
| 20 | - protected function setupRequest() { |
|
| 20 | + protected function setupRequest(){ |
|
| 21 | 21 | $this->Request = new GETFile(); |
| 22 | 22 | } |
| 23 | 23 | |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | * @inheritdoc |
| 26 | 26 | * File Response Object has option File Destination parameter, which is passed using DownloadDir property |
| 27 | 27 | */ |
| 28 | - protected function setupResponse() { |
|
| 29 | - $this->Response = new FileResponse($this->Request->getResponse(),$this->Request->getCurlObject(),$this->downloadDir); |
|
| 28 | + protected function setupResponse(){ |
|
| 29 | + $this->Response = new FileResponse($this->Request->getResponse(), $this->Request->getCurlObject(), $this->downloadDir); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * @inheritdoc |
| 19 | 19 | */ |
| 20 | - protected function setupRequest() { |
|
| 20 | + protected function setupRequest(){ |
|
| 21 | 21 | $this->Request = new GETFile(); |
| 22 | 22 | } |
| 23 | 23 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @inheritdoc |
| 26 | 26 | * File Response Object has option File Destination parameter, which is passed using DownloadDir property |
| 27 | 27 | */ |
| 28 | - protected function setupResponse() { |
|
| 28 | + protected function setupResponse(){ |
|
| 29 | 29 | $this->Response = new FileResponse($this->Request->getResponse(),$this->Request->getCurlObject(),$this->downloadDir); |
| 30 | 30 | } |
| 31 | 31 | |
@@ -12,7 +12,7 @@ |
||
| 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 | /** |
| 18 | 18 | * @inheritdoc |