@@ -32,7 +32,7 @@ |
||
32 | 32 | $postData = [ |
33 | 33 | 'method' => 'post', |
34 | 34 | 'key' => $this->apiKey, |
35 | - 'file' => (version_compare(PHP_VERSION, '5.5.0') >= 0) ? new \CURLFile($filePath) : '@'.$filePath, |
|
35 | + 'file' => (version_compare(PHP_VERSION, '5.5.0') >= 0) ? new \CURLFile($filePath) : '@' . $filePath, |
|
36 | 36 | 'phrase' => $this->isPhrase, |
37 | 37 | 'regsense' => $this->isRegSense, |
38 | 38 | 'numeric' => $this->isNumeric, |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | public function testGetBaseUrl() |
20 | 20 | { |
21 | 21 | $abstract = $this->newInstance(); |
22 | - $getBaseUrlCaller = function () { |
|
22 | + $getBaseUrlCaller = function() { |
|
23 | 23 | $this->domain = 'domain'; |
24 | 24 | return $this->getBaseUrl(); |
25 | 25 | }; |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | public function testGetFilePath() |
52 | 52 | { |
53 | 53 | $abstract = $this->newInstance(); |
54 | - $getFilePathCaller = function ($val) { |
|
54 | + $getFilePathCaller = function($val) { |
|
55 | 55 | return $this->getFilePath($val); |
56 | 56 | }; |
57 | 57 | $bound = $getFilePathCaller->bindTo($abstract, $abstract); |
58 | - $this->assertEquals(__DIR__.'/data/Captcha.jpg', $bound(__DIR__.'/data/Captcha.jpg')); |
|
58 | + $this->assertEquals(__DIR__ . '/data/Captcha.jpg', $bound(__DIR__ . '/data/Captcha.jpg')); |
|
59 | 59 | $filePathUpload = $bound('https://upload.wikimedia.org/wikipedia/commons/6/69/Captcha.jpg'); |
60 | - $file1 = file_get_contents(__DIR__.'/data/Captcha.jpg'); |
|
60 | + $file1 = file_get_contents(__DIR__ . '/data/Captcha.jpg'); |
|
61 | 61 | $file2 = file_get_contents($filePathUpload); |
62 | 62 | $this->assertEquals($file1, $file2); |
63 | 63 | } |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | public function testGetFilePathErrorFileNotFound() |
70 | 70 | { |
71 | 71 | $abstract = $this->newInstance(); |
72 | - $getFilePathCaller = function ($val) { |
|
72 | + $getFilePathCaller = function($val) { |
|
73 | 73 | return $this->getFilePath($val); |
74 | 74 | }; |
75 | 75 | $bound = $getFilePathCaller->bindTo($abstract, $abstract); |
76 | - $bound(__DIR__.'/data/Captcha1.jpg'); |
|
76 | + $bound(__DIR__ . '/data/Captcha1.jpg'); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | public function testGetFilePathErrorFileIsNotLoaded() |
85 | 85 | { |
86 | 86 | $abstract = $this->newInstance(); |
87 | - $getFilePathCaller = function ($val) { |
|
87 | + $getFilePathCaller = function($val) { |
|
88 | 88 | return $this->getFilePath($val); |
89 | 89 | }; |
90 | 90 | $bound = $getFilePathCaller->bindTo($abstract, $abstract); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | public function testIsError() |
158 | 158 | { |
159 | 159 | $abstract = $this->newInstance(); |
160 | - $isErrorCaller = function ($val) { |
|
160 | + $isErrorCaller = function($val) { |
|
161 | 161 | return $this->isError($val); |
162 | 162 | }; |
163 | 163 | $bound = $isErrorCaller->bindTo($abstract, $abstract); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | public function testIsErrorNot() |
168 | 168 | { |
169 | 169 | $abstract = $this->newInstance(); |
170 | - $isErrorCaller = function ($val) { |
|
170 | + $isErrorCaller = function($val) { |
|
171 | 171 | return $this->isError($val); |
172 | 172 | }; |
173 | 173 | $bound = $isErrorCaller->bindTo($abstract, $abstract); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | public function testGetCurlResponseError() |
183 | 183 | { |
184 | 184 | $abstract = $this->newInstance(); |
185 | - $getCurlResponseCaller = function ($url, $val) { |
|
185 | + $getCurlResponseCaller = function($url, $val) { |
|
186 | 186 | return $this->getCurlResponse($url, $val); |
187 | 187 | }; |
188 | 188 | $bound = $getCurlResponseCaller->bindTo($abstract, $abstract); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | public function testGetCurlResponse() |
193 | 193 | { |
194 | 194 | $abstract = $this->newInstance(); |
195 | - $getCurlResponseCaller = function ($url, $val) { |
|
195 | + $getCurlResponseCaller = function($url, $val) { |
|
196 | 196 | return $this->getCurlResponse($url, $val); |
197 | 197 | }; |
198 | 198 | $bound = $getCurlResponseCaller->bindTo($abstract, $abstract); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | switch ($param) { |
129 | 129 | case static::PARAM_SPEC_FILE: |
130 | - return (version_compare(PHP_VERSION, '5.5.0') >= 0) ? new \CURLFile($this->paramsSpec[$param]) : '@'.$this->paramsSpec[$param]; |
|
130 | + return (version_compare(PHP_VERSION, '5.5.0') >= 0) ? new \CURLFile($this->paramsSpec[$param]) : '@' . $this->paramsSpec[$param]; |
|
131 | 131 | case static::PARAM_SPEC_KEY: |
132 | 132 | return is_callable($this->paramsSpec[$param]) ? $this->paramsSpec[$param]() : $this->paramsSpec[$param]; |
133 | 133 | case static::PARAM_SPEC_CAPTCHA: |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | $uri[] = "$key=$value"; |
185 | 185 | } |
186 | 186 | |
187 | - return "{$this->getBaseUrl()}{$this->resUrl}?".implode('&', $uri); |
|
187 | + return "{$this->getBaseUrl()}{$this->resUrl}?" . implode('&', $uri); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | protected function getInUrl() |
204 | 204 | { |
205 | - return $this->getBaseUrl().$this->inUrl; |
|
205 | + return $this->getBaseUrl() . $this->inUrl; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -115,6 +115,10 @@ discard block |
||
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | + /** |
|
119 | + * @param integer $param |
|
120 | + * @param string $value |
|
121 | + */ |
|
118 | 122 | public function setParamSpec($param, $value) |
119 | 123 | { |
120 | 124 | $this->paramsSpec[$param] = $value; |
@@ -137,6 +141,9 @@ discard block |
||
137 | 141 | return null; |
138 | 142 | } |
139 | 143 | |
144 | + /** |
|
145 | + * @param integer $action |
|
146 | + */ |
|
140 | 147 | protected function getParams($action) |
141 | 148 | { |
142 | 149 | if (empty($this->paramsSettings[$action])) { |
@@ -173,7 +180,7 @@ discard block |
||
173 | 180 | } |
174 | 181 | |
175 | 182 | /** |
176 | - * @param array $data |
|
183 | + * @param string $data |
|
177 | 184 | * |
178 | 185 | * @return string |
179 | 186 | */ |
@@ -217,8 +217,7 @@ |
||
217 | 217 | } |
218 | 218 | $decodeSetting = $this->decodeSettings[static::DECODE_ACTION][$action]; |
219 | 219 | $decodeFormat = array_key_exists(static::DECODE_FORMAT, $decodeSetting) ? |
220 | - $decodeSetting[static::DECODE_FORMAT] : |
|
221 | - $this->decodeSettings[static::DECODE_FORMAT]; |
|
220 | + $decodeSetting[static::DECODE_FORMAT] : $this->decodeSettings[static::DECODE_FORMAT]; |
|
222 | 221 | $values = []; |
223 | 222 | switch ($decodeFormat) { |
224 | 223 | case static::RESPONSE_TYPE_STRING: |
@@ -247,6 +247,9 @@ |
||
247 | 247 | ], |
248 | 248 | ]; |
249 | 249 | |
250 | + /** |
|
251 | + * @param integer $action |
|
252 | + */ |
|
250 | 253 | protected function decodeResponse($action, $data) |
251 | 254 | { |
252 | 255 | if (!array_key_exists($action, $this->decodeSettings[static::DECODE_ACTION])) { |