@@ -22,19 +22,19 @@ discard block |
||
22 | 22 | { |
23 | 23 | const ERROR_NO_BOUNDARIES_SPECIFIED = 44401; |
24 | 24 | |
25 | - /** |
|
26 | - * @var RequestHelper |
|
27 | - */ |
|
25 | + /** |
|
26 | + * @var RequestHelper |
|
27 | + */ |
|
28 | 28 | protected $helper; |
29 | 29 | |
30 | - /** |
|
31 | - * @var RequestHelper_Boundaries_Boundary[] |
|
32 | - */ |
|
30 | + /** |
|
31 | + * @var RequestHelper_Boundaries_Boundary[] |
|
32 | + */ |
|
33 | 33 | protected $boundaries = array(); |
34 | 34 | |
35 | - /** |
|
36 | - * @var integer |
|
37 | - */ |
|
35 | + /** |
|
36 | + * @var integer |
|
37 | + */ |
|
38 | 38 | protected $contentLength = 0; |
39 | 39 | |
40 | 40 | public function __construct(RequestHelper $helper) |
@@ -42,45 +42,45 @@ discard block |
||
42 | 42 | $this->helper = $helper; |
43 | 43 | } |
44 | 44 | |
45 | - /** |
|
46 | - * Retrieves the string that is used to separate mime boundaries in the body. |
|
47 | - * |
|
48 | - * @return string |
|
49 | - */ |
|
45 | + /** |
|
46 | + * Retrieves the string that is used to separate mime boundaries in the body. |
|
47 | + * |
|
48 | + * @return string |
|
49 | + */ |
|
50 | 50 | public function getMimeBoundary() : string |
51 | 51 | { |
52 | 52 | return $this->helper->getMimeBoundary(); |
53 | 53 | } |
54 | 54 | |
55 | - /** |
|
56 | - * Retrieves the end of line character(s) used in the body. |
|
57 | - * |
|
58 | - * @return string |
|
59 | - */ |
|
55 | + /** |
|
56 | + * Retrieves the end of line character(s) used in the body. |
|
57 | + * |
|
58 | + * @return string |
|
59 | + */ |
|
60 | 60 | public function getEOL() : string |
61 | 61 | { |
62 | 62 | return $this->helper->getEOL(); |
63 | 63 | } |
64 | 64 | |
65 | - /** |
|
66 | - * Retrieves the total content length of all boundary contents. |
|
67 | - * |
|
68 | - * @return int |
|
69 | - */ |
|
65 | + /** |
|
66 | + * Retrieves the total content length of all boundary contents. |
|
67 | + * |
|
68 | + * @return int |
|
69 | + */ |
|
70 | 70 | public function getContentLength() : int |
71 | 71 | { |
72 | 72 | return mb_strlen($this->render()); |
73 | 73 | } |
74 | 74 | |
75 | - /** |
|
76 | - * Adds a file to be sent with the request. |
|
77 | - * |
|
78 | - * @param string $varName The variable name to send the file in |
|
79 | - * @param string $fileName The name of the file as it should be received at the destination |
|
80 | - * @param string $content The raw content of the file |
|
81 | - * @param string $contentType The content type, use the constants to specify this |
|
82 | - * @param string $encoding The encoding of the file, use the constants to specify this |
|
83 | - */ |
|
75 | + /** |
|
76 | + * Adds a file to be sent with the request. |
|
77 | + * |
|
78 | + * @param string $varName The variable name to send the file in |
|
79 | + * @param string $fileName The name of the file as it should be received at the destination |
|
80 | + * @param string $content The raw content of the file |
|
81 | + * @param string $contentType The content type, use the constants to specify this |
|
82 | + * @param string $encoding The encoding of the file, use the constants to specify this |
|
83 | + */ |
|
84 | 84 | public function addFile(string $varName, string $fileName, string $content, string $contentType = '', string $encoding = '') : RequestHelper_Boundaries |
85 | 85 | { |
86 | 86 | if(empty($contentType)) |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | return $this->addBoundary($boundary); |
105 | 105 | } |
106 | 106 | |
107 | - /** |
|
108 | - * Adds arbitrary content. |
|
109 | - * |
|
110 | - * @param string $varName |
|
111 | - * @param string $content |
|
112 | - * @param string $contentType |
|
113 | - */ |
|
107 | + /** |
|
108 | + * Adds arbitrary content. |
|
109 | + * |
|
110 | + * @param string $varName |
|
111 | + * @param string $content |
|
112 | + * @param string $contentType |
|
113 | + */ |
|
114 | 114 | public function addContent(string $varName, string $content, string $contentType) : RequestHelper_Boundaries |
115 | 115 | { |
116 | 116 | $content = ConvertHelper::string2utf8($content); |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | return $this->addBoundary($boundary); |
125 | 125 | } |
126 | 126 | |
127 | - /** |
|
128 | - * Adds a variable to be sent with the request. If it |
|
129 | - * already exists, its value is overwritten. |
|
130 | - * |
|
131 | - * @param string $name |
|
132 | - * @param string $value |
|
133 | - */ |
|
127 | + /** |
|
128 | + * Adds a variable to be sent with the request. If it |
|
129 | + * already exists, its value is overwritten. |
|
130 | + * |
|
131 | + * @param string $name |
|
132 | + * @param string $value |
|
133 | + */ |
|
134 | 134 | public function addVariable(string $name, string $value) : RequestHelper_Boundaries |
135 | 135 | { |
136 | 136 | $boundary = $this->createBoundary($value) |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | return $this; |
147 | 147 | } |
148 | 148 | |
149 | - /** |
|
150 | - * Renders the response body with all mime boundaries. |
|
151 | - * |
|
152 | - * @return string |
|
153 | - */ |
|
149 | + /** |
|
150 | + * Renders the response body with all mime boundaries. |
|
151 | + * |
|
152 | + * @return string |
|
153 | + */ |
|
154 | 154 | public function render() : string |
155 | 155 | { |
156 | 156 | if(empty($this->boundaries)) |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function addFile(string $varName, string $fileName, string $content, string $contentType = '', string $encoding = '') : RequestHelper_Boundaries |
85 | 85 | { |
86 | - if(empty($contentType)) |
|
86 | + if (empty($contentType)) |
|
87 | 87 | { |
88 | 88 | $contentType = FileHelper::detectMimeType($fileName); |
89 | 89 | } |
90 | 90 | |
91 | - if(empty($encoding)) |
|
91 | + if (empty($encoding)) |
|
92 | 92 | { |
93 | 93 | $encoding = RequestHelper::ENCODING_UTF8; |
94 | 94 | $content = ConvertHelper::string2utf8($content); |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function render() : string |
155 | 155 | { |
156 | - if(empty($this->boundaries)) |
|
156 | + if (empty($this->boundaries)) |
|
157 | 157 | { |
158 | 158 | throw new RequestHelper_Exception( |
159 | 159 | 'No mime boundaries added', |
@@ -164,13 +164,13 @@ discard block |
||
164 | 164 | |
165 | 165 | $result = ''; |
166 | 166 | |
167 | - foreach($this->boundaries as $boundary) |
|
167 | + foreach ($this->boundaries as $boundary) |
|
168 | 168 | { |
169 | 169 | $result .= $boundary->render(); |
170 | 170 | } |
171 | 171 | |
172 | - $result .= "--" . $this->getMimeBoundary() . "--" . |
|
173 | - $this->getEOL() . $this->getEOL(); // always finish with two eol's!! |
|
172 | + $result .= "--".$this->getMimeBoundary()."--". |
|
173 | + $this->getEOL().$this->getEOL(); // always finish with two eol's!! |
|
174 | 174 | |
175 | 175 | return $result; |
176 | 176 | } |
@@ -19,34 +19,34 @@ discard block |
||
19 | 19 | */ |
20 | 20 | class RequestHelper_Boundaries_Boundary |
21 | 21 | { |
22 | - /** |
|
23 | - * @var string |
|
24 | - */ |
|
22 | + /** |
|
23 | + * @var string |
|
24 | + */ |
|
25 | 25 | protected $content; |
26 | 26 | |
27 | - /** |
|
28 | - * @var array |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var array |
|
29 | + */ |
|
30 | 30 | protected $dispositionParams = array(); |
31 | 31 | |
32 | - /** |
|
33 | - * @var string |
|
34 | - */ |
|
32 | + /** |
|
33 | + * @var string |
|
34 | + */ |
|
35 | 35 | protected $contentType = ''; |
36 | 36 | |
37 | - /** |
|
38 | - * @var string |
|
39 | - */ |
|
37 | + /** |
|
38 | + * @var string |
|
39 | + */ |
|
40 | 40 | protected $contentEncoding = ''; |
41 | 41 | |
42 | - /** |
|
43 | - * @var RequestHelper_Boundaries |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var RequestHelper_Boundaries |
|
44 | + */ |
|
45 | 45 | protected $boundaries; |
46 | 46 | |
47 | - /** |
|
48 | - * @var string |
|
49 | - */ |
|
47 | + /** |
|
48 | + * @var string |
|
49 | + */ |
|
50 | 50 | protected $transferEncoding = ''; |
51 | 51 | |
52 | 52 | public function __construct(RequestHelper_Boundaries $boundaries, string $content) |
@@ -60,46 +60,46 @@ discard block |
||
60 | 60 | return strlen($this->content); |
61 | 61 | } |
62 | 62 | |
63 | - /** |
|
64 | - * Sets the name of the request parameter. |
|
65 | - * |
|
66 | - * @param string $name |
|
67 | - * @return RequestHelper_Boundaries_Boundary |
|
68 | - */ |
|
63 | + /** |
|
64 | + * Sets the name of the request parameter. |
|
65 | + * |
|
66 | + * @param string $name |
|
67 | + * @return RequestHelper_Boundaries_Boundary |
|
68 | + */ |
|
69 | 69 | public function setName(string $name) : RequestHelper_Boundaries_Boundary |
70 | 70 | { |
71 | 71 | return $this->setDispositionParam('name', $name); |
72 | 72 | } |
73 | 73 | |
74 | - /** |
|
75 | - * Sets the filename to use for the content, if applicable. |
|
76 | - * |
|
77 | - * @param string $fileName |
|
78 | - * @return RequestHelper_Boundaries_Boundary |
|
79 | - */ |
|
74 | + /** |
|
75 | + * Sets the filename to use for the content, if applicable. |
|
76 | + * |
|
77 | + * @param string $fileName |
|
78 | + * @return RequestHelper_Boundaries_Boundary |
|
79 | + */ |
|
80 | 80 | public function setFileName(string $fileName) : RequestHelper_Boundaries_Boundary |
81 | 81 | { |
82 | 82 | return $this->setDispositionParam('filename', $fileName); |
83 | 83 | } |
84 | 84 | |
85 | - /** |
|
86 | - * Sets the content type to use for the content. |
|
87 | - * |
|
88 | - * @param string $contentType |
|
89 | - * @return RequestHelper_Boundaries_Boundary |
|
90 | - */ |
|
85 | + /** |
|
86 | + * Sets the content type to use for the content. |
|
87 | + * |
|
88 | + * @param string $contentType |
|
89 | + * @return RequestHelper_Boundaries_Boundary |
|
90 | + */ |
|
91 | 91 | public function setContentType(string $contentType) : RequestHelper_Boundaries_Boundary |
92 | 92 | { |
93 | 93 | $this->contentType = $contentType; |
94 | 94 | return $this; |
95 | 95 | } |
96 | 96 | |
97 | - /** |
|
98 | - * Sets the encoding to specify for the content. |
|
99 | - * |
|
100 | - * @param string $encoding An encoding string, e.g. "UTF-8", "ASCII" |
|
101 | - * @return RequestHelper_Boundaries_Boundary |
|
102 | - */ |
|
97 | + /** |
|
98 | + * Sets the encoding to specify for the content. |
|
99 | + * |
|
100 | + * @param string $encoding An encoding string, e.g. "UTF-8", "ASCII" |
|
101 | + * @return RequestHelper_Boundaries_Boundary |
|
102 | + */ |
|
103 | 103 | public function setContentEncoding(string $encoding) : RequestHelper_Boundaries_Boundary |
104 | 104 | { |
105 | 105 | $this->contentEncoding = $encoding; |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | return $this; |
120 | 120 | } |
121 | 121 | |
122 | - /** |
|
123 | - * Renders the mime boundary text. |
|
124 | - * |
|
125 | - * @return string |
|
126 | - */ |
|
122 | + /** |
|
123 | + * Renders the mime boundary text. |
|
124 | + * |
|
125 | + * @return string |
|
126 | + */ |
|
127 | 127 | public function render() |
128 | 128 | { |
129 | 129 | $eol = $this->boundaries->getEOL(); |
@@ -132,12 +132,12 @@ discard block |
||
132 | 132 | $lines[] = '--'.$this->boundaries->getMimeBoundary(); |
133 | 133 | $lines[] = $this->renderContentDisposition(); |
134 | 134 | |
135 | - if(!empty($this->contentType)) |
|
135 | + if (!empty($this->contentType)) |
|
136 | 136 | { |
137 | 137 | $lines[] = $this->renderContentType(); |
138 | 138 | } |
139 | 139 | |
140 | - if(!empty($this->transferEncoding)) |
|
140 | + if (!empty($this->transferEncoding)) |
|
141 | 141 | { |
142 | 142 | $lines[] = $this->renderTransferEncoding(); |
143 | 143 | } |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | { |
153 | 153 | $result = 'Content-Disposition: form-data'; |
154 | 154 | |
155 | - foreach($this->dispositionParams as $name => $value) |
|
155 | + foreach ($this->dispositionParams as $name => $value) |
|
156 | 156 | { |
157 | - $result .= '; '.$name.'="' . $value . '"'; |
|
157 | + $result .= '; '.$name.'="'.$value.'"'; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | return $result; |
@@ -162,11 +162,11 @@ discard block |
||
162 | 162 | |
163 | 163 | protected function renderContentType() : string |
164 | 164 | { |
165 | - $result = 'Content-Type: ' . $this->contentType; |
|
165 | + $result = 'Content-Type: '.$this->contentType; |
|
166 | 166 | |
167 | - if(!empty($this->contentEncoding)) |
|
167 | + if (!empty($this->contentEncoding)) |
|
168 | 168 | { |
169 | - $result .= '; charset="' . $this->contentEncoding.'"'; |
|
169 | + $result .= '; charset="'.$this->contentEncoding.'"'; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | return $result; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | protected function renderTransferEncoding() : string |
176 | 176 | { |
177 | - $result = 'Content-Transfer-Encoding: ' . $this->transferEncoding; |
|
177 | + $result = 'Content-Transfer-Encoding: '.$this->transferEncoding; |
|
178 | 178 | |
179 | 179 | return $result; |
180 | 180 | } |
@@ -39,66 +39,66 @@ discard block |
||
39 | 39 | |
40 | 40 | const ERROR_CANNOT_OPEN_LOGFILE = 17904; |
41 | 41 | |
42 | - /** |
|
43 | - * @var string |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var string |
|
44 | + */ |
|
45 | 45 | protected $eol = "\r\n"; |
46 | 46 | |
47 | - /** |
|
48 | - * @var string |
|
49 | - */ |
|
47 | + /** |
|
48 | + * @var string |
|
49 | + */ |
|
50 | 50 | protected $mimeBoundary; |
51 | 51 | |
52 | - /** |
|
53 | - * @var string |
|
54 | - */ |
|
52 | + /** |
|
53 | + * @var string |
|
54 | + */ |
|
55 | 55 | protected $data = ''; |
56 | 56 | |
57 | - /** |
|
58 | - * @var string |
|
59 | - */ |
|
57 | + /** |
|
58 | + * @var string |
|
59 | + */ |
|
60 | 60 | protected $destination; |
61 | 61 | |
62 | - /** |
|
63 | - * @var array |
|
64 | - */ |
|
62 | + /** |
|
63 | + * @var array |
|
64 | + */ |
|
65 | 65 | protected $headers = array(); |
66 | 66 | |
67 | - /** |
|
68 | - * Whether to verify SSL certificates. |
|
69 | - * @var bool |
|
70 | - */ |
|
67 | + /** |
|
68 | + * Whether to verify SSL certificates. |
|
69 | + * @var bool |
|
70 | + */ |
|
71 | 71 | protected $verifySSL = true; |
72 | 72 | |
73 | - /** |
|
74 | - * @var RequestHelper_Boundaries |
|
75 | - */ |
|
73 | + /** |
|
74 | + * @var RequestHelper_Boundaries |
|
75 | + */ |
|
76 | 76 | protected $boundaries; |
77 | 77 | |
78 | - /** |
|
79 | - * @var RequestHelper_Response|NULL |
|
80 | - */ |
|
78 | + /** |
|
79 | + * @var RequestHelper_Response|NULL |
|
80 | + */ |
|
81 | 81 | protected $response; |
82 | 82 | |
83 | - /** |
|
84 | - * @var integer |
|
85 | - */ |
|
83 | + /** |
|
84 | + * @var integer |
|
85 | + */ |
|
86 | 86 | protected $timeout = 30; |
87 | 87 | |
88 | - /** |
|
89 | - * @var string |
|
90 | - */ |
|
88 | + /** |
|
89 | + * @var string |
|
90 | + */ |
|
91 | 91 | protected $logfile = ''; |
92 | 92 | |
93 | - /** |
|
94 | - * @var resource|NULL |
|
95 | - */ |
|
93 | + /** |
|
94 | + * @var resource|NULL |
|
95 | + */ |
|
96 | 96 | protected $logfilePointer = null; |
97 | 97 | |
98 | - /** |
|
99 | - * Creates a new request helper to send POST data to the specified destination URL. |
|
100 | - * @param string $destinationURL |
|
101 | - */ |
|
98 | + /** |
|
99 | + * Creates a new request helper to send POST data to the specified destination URL. |
|
100 | + * @param string $destinationURL |
|
101 | + */ |
|
102 | 102 | public function __construct(string $destinationURL) |
103 | 103 | { |
104 | 104 | $this->destination = $destinationURL; |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | return $this; |
131 | 131 | } |
132 | 132 | |
133 | - /** |
|
134 | - * Enables verbose logging of the CURL request, which |
|
135 | - * is then redirected to the target file. |
|
136 | - * |
|
137 | - * @param string $targetFile |
|
138 | - * @return RequestHelper |
|
139 | - */ |
|
133 | + /** |
|
134 | + * Enables verbose logging of the CURL request, which |
|
135 | + * is then redirected to the target file. |
|
136 | + * |
|
137 | + * @param string $targetFile |
|
138 | + * @return RequestHelper |
|
139 | + */ |
|
140 | 140 | public function enableLogging(string $targetFile) : RequestHelper |
141 | 141 | { |
142 | 142 | $this->logfile = $targetFile; |
@@ -144,15 +144,15 @@ discard block |
||
144 | 144 | return $this; |
145 | 145 | } |
146 | 146 | |
147 | - /** |
|
148 | - * Adds a file to be sent with the request. |
|
149 | - * |
|
150 | - * @param string $varName The variable name to send the file in |
|
151 | - * @param string $fileName The name of the file as it should be received at the destination |
|
152 | - * @param string $content The raw content of the file |
|
153 | - * @param string $contentType The content type, use the constants to specify this |
|
154 | - * @param string $encoding The encoding of the file, use the constants to specify this |
|
155 | - */ |
|
147 | + /** |
|
148 | + * Adds a file to be sent with the request. |
|
149 | + * |
|
150 | + * @param string $varName The variable name to send the file in |
|
151 | + * @param string $fileName The name of the file as it should be received at the destination |
|
152 | + * @param string $content The raw content of the file |
|
153 | + * @param string $contentType The content type, use the constants to specify this |
|
154 | + * @param string $encoding The encoding of the file, use the constants to specify this |
|
155 | + */ |
|
156 | 156 | public function addFile(string $varName, string $fileName, string $content, string $contentType = '', string $encoding = '') : RequestHelper |
157 | 157 | { |
158 | 158 | $this->boundaries->addFile($varName, $fileName, $content, $contentType, $encoding); |
@@ -160,13 +160,13 @@ discard block |
||
160 | 160 | return $this; |
161 | 161 | } |
162 | 162 | |
163 | - /** |
|
164 | - * Adds arbitrary content. |
|
165 | - * |
|
166 | - * @param string $varName The variable name to send the content in. |
|
167 | - * @param string $content |
|
168 | - * @param string $contentType |
|
169 | - */ |
|
163 | + /** |
|
164 | + * Adds arbitrary content. |
|
165 | + * |
|
166 | + * @param string $varName The variable name to send the content in. |
|
167 | + * @param string $content |
|
168 | + * @param string $contentType |
|
169 | + */ |
|
170 | 170 | public function addContent(string $varName, string $content, string $contentType) : RequestHelper |
171 | 171 | { |
172 | 172 | $this->boundaries->addContent($varName, $content, $contentType); |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | return $this; |
189 | 189 | } |
190 | 190 | |
191 | - /** |
|
192 | - * Sets an HTTP header to include in the request. |
|
193 | - * |
|
194 | - * @param string $name |
|
195 | - * @param string $value |
|
196 | - * @return RequestHelper |
|
197 | - */ |
|
191 | + /** |
|
192 | + * Sets an HTTP header to include in the request. |
|
193 | + * |
|
194 | + * @param string $name |
|
195 | + * @param string $value |
|
196 | + * @return RequestHelper |
|
197 | + */ |
|
198 | 198 | public function setHeader(string $name, string $value) : RequestHelper |
199 | 199 | { |
200 | 200 | $this->headers[$name] = $value; |
@@ -202,36 +202,36 @@ discard block |
||
202 | 202 | return $this; |
203 | 203 | } |
204 | 204 | |
205 | - /** |
|
206 | - * Disables SSL certificate checking. |
|
207 | - * |
|
208 | - * @return RequestHelper |
|
209 | - */ |
|
205 | + /** |
|
206 | + * Disables SSL certificate checking. |
|
207 | + * |
|
208 | + * @return RequestHelper |
|
209 | + */ |
|
210 | 210 | public function disableSSLChecks() : RequestHelper |
211 | 211 | { |
212 | 212 | $this->verifySSL = false; |
213 | 213 | return $this; |
214 | 214 | } |
215 | 215 | |
216 | - /** |
|
217 | - * @var integer |
|
218 | - */ |
|
216 | + /** |
|
217 | + * @var integer |
|
218 | + */ |
|
219 | 219 | protected $contentLength = 0; |
220 | 220 | |
221 | - /** |
|
222 | - * Sends the POST request to the destination, and returns |
|
223 | - * the response text. |
|
224 | - * |
|
225 | - * The response object is stored internally, so after calling |
|
226 | - * this method it may be retrieved at any moment using the |
|
227 | - * {@link getResponse()} method. |
|
228 | - * |
|
229 | - * @return string |
|
230 | - * @see RequestHelper::getResponse() |
|
231 | - * @throws RequestHelper_Exception |
|
232 | - * |
|
233 | - * @see RequestHelper::ERROR_REQUEST_FAILED |
|
234 | - */ |
|
221 | + /** |
|
222 | + * Sends the POST request to the destination, and returns |
|
223 | + * the response text. |
|
224 | + * |
|
225 | + * The response object is stored internally, so after calling |
|
226 | + * this method it may be retrieved at any moment using the |
|
227 | + * {@link getResponse()} method. |
|
228 | + * |
|
229 | + * @return string |
|
230 | + * @see RequestHelper::getResponse() |
|
231 | + * @throws RequestHelper_Exception |
|
232 | + * |
|
233 | + * @see RequestHelper::ERROR_REQUEST_FAILED |
|
234 | + */ |
|
235 | 235 | public function send() : string |
236 | 236 | { |
237 | 237 | $info = parseURL($this->destination); |
@@ -274,14 +274,14 @@ discard block |
||
274 | 274 | return $this->data; |
275 | 275 | } |
276 | 276 | |
277 | - /** |
|
278 | - * Creates a new CURL resource configured according to the |
|
279 | - * request's settings. |
|
280 | - * |
|
281 | - * @param URLInfo $url |
|
282 | - * @throws RequestHelper_Exception |
|
283 | - * @return resource |
|
284 | - */ |
|
277 | + /** |
|
278 | + * Creates a new CURL resource configured according to the |
|
279 | + * request's settings. |
|
280 | + * |
|
281 | + * @param URLInfo $url |
|
282 | + * @throws RequestHelper_Exception |
|
283 | + * @return resource |
|
284 | + */ |
|
285 | 285 | protected function createCURL(URLInfo $url) |
286 | 286 | { |
287 | 287 | $ch = curl_init(); |
@@ -329,10 +329,10 @@ discard block |
||
329 | 329 | return $ch; |
330 | 330 | } |
331 | 331 | |
332 | - /** |
|
333 | - * @param resource $ch |
|
334 | - * @return bool Whether logging is enabled. |
|
335 | - */ |
|
332 | + /** |
|
333 | + * @param resource $ch |
|
334 | + * @return bool Whether logging is enabled. |
|
335 | + */ |
|
336 | 336 | protected function configureLogging($ch) : bool |
337 | 337 | { |
338 | 338 | if(empty($this->logfile)) |
@@ -359,13 +359,13 @@ discard block |
||
359 | 359 | return true; |
360 | 360 | } |
361 | 361 | |
362 | - /** |
|
363 | - * Compiles the associative headers array into |
|
364 | - * the format understood by CURL, namely an indexed |
|
365 | - * array with one header string per entry. |
|
366 | - * |
|
367 | - * @return array |
|
368 | - */ |
|
362 | + /** |
|
363 | + * Compiles the associative headers array into |
|
364 | + * the format understood by CURL, namely an indexed |
|
365 | + * array with one header string per entry. |
|
366 | + * |
|
367 | + * @return array |
|
368 | + */ |
|
369 | 369 | protected function renderHeaders() : array |
370 | 370 | { |
371 | 371 | $result = array(); |
@@ -379,12 +379,12 @@ discard block |
||
379 | 379 | return $result; |
380 | 380 | } |
381 | 381 | |
382 | - /** |
|
383 | - * Retrieves the raw response header, in the form of an indexed |
|
384 | - * array containing all response header lines. |
|
385 | - * |
|
386 | - * @return array |
|
387 | - */ |
|
382 | + /** |
|
383 | + * Retrieves the raw response header, in the form of an indexed |
|
384 | + * array containing all response header lines. |
|
385 | + * |
|
386 | + * @return array |
|
387 | + */ |
|
388 | 388 | public function getResponseHeader() : array |
389 | 389 | { |
390 | 390 | $response = $this->getResponse(); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | |
241 | 241 | $output = curl_exec($ch); |
242 | 242 | |
243 | - if(isset($this->logfilePointer)) |
|
243 | + if (isset($this->logfilePointer)) |
|
244 | 244 | { |
245 | 245 | fclose($this->logfilePointer); |
246 | 246 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | // CURL will complain about an empty response when the |
253 | 253 | // server sends a 100-continue code. That should not be |
254 | 254 | // regarded as an error. |
255 | - if($output === false && $this->response->getCode() !== 100) |
|
255 | + if ($output === false && $this->response->getCode() !== 100) |
|
256 | 256 | { |
257 | 257 | $this->response->setError( |
258 | 258 | curl_errno($ch), |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | { |
287 | 287 | $ch = curl_init(); |
288 | 288 | |
289 | - if(!is_resource($ch)) |
|
289 | + if (!is_resource($ch)) |
|
290 | 290 | { |
291 | 291 | throw new RequestHelper_Exception( |
292 | 292 | 'Could not initialize a new cURL instance.', |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | } |
297 | 297 | |
298 | 298 | $this->setHeader('Content-Length', (string)$this->boundaries->getContentLength()); |
299 | - $this->setHeader('Content-Type', 'multipart/form-data; boundary=' . $this->mimeBoundary); |
|
299 | + $this->setHeader('Content-Type', 'multipart/form-data; boundary='.$this->mimeBoundary); |
|
300 | 300 | |
301 | 301 | curl_setopt($ch, CURLOPT_POST, true); |
302 | 302 | curl_setopt($ch, CURLOPT_URL, $url->getNormalizedWithoutAuth()); |
@@ -309,18 +309,18 @@ discard block |
||
309 | 309 | |
310 | 310 | $loggingEnabled = $this->configureLogging($ch); |
311 | 311 | |
312 | - if(!$loggingEnabled) |
|
312 | + if (!$loggingEnabled) |
|
313 | 313 | { |
314 | 314 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
315 | 315 | } |
316 | 316 | |
317 | - if($this->verifySSL) |
|
317 | + if ($this->verifySSL) |
|
318 | 318 | { |
319 | 319 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
320 | 320 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
321 | 321 | } |
322 | 322 | |
323 | - if($url->hasUsername()) |
|
323 | + if ($url->hasUsername()) |
|
324 | 324 | { |
325 | 325 | curl_setopt($ch, CURLOPT_USERNAME, $url->getUsername()); |
326 | 326 | curl_setopt($ch, CURLOPT_PASSWORD, $url->getPassword()); |
@@ -335,14 +335,14 @@ discard block |
||
335 | 335 | */ |
336 | 336 | protected function configureLogging($ch) : bool |
337 | 337 | { |
338 | - if(empty($this->logfile)) |
|
338 | + if (empty($this->logfile)) |
|
339 | 339 | { |
340 | 340 | return false; |
341 | 341 | } |
342 | 342 | |
343 | 343 | $res = fopen($this->logfile, 'w+'); |
344 | 344 | |
345 | - if($res === false) |
|
345 | + if ($res === false) |
|
346 | 346 | { |
347 | 347 | throw new RequestHelper_Exception( |
348 | 348 | 'Cannot open logfile for writing.', |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | |
373 | 373 | $this->setHeader('Expect', ''); |
374 | 374 | |
375 | - foreach($this->headers as $name => $value) { |
|
375 | + foreach ($this->headers as $name => $value) { |
|
376 | 376 | $result[] = $name.': '.$value; |
377 | 377 | } |
378 | 378 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | { |
390 | 390 | $response = $this->getResponse(); |
391 | 391 | |
392 | - if($response !== null) { |
|
392 | + if ($response !== null) { |
|
393 | 393 | return $response->getHeaders(); |
394 | 394 | } |
395 | 395 |