@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | public function testGetBaseUrl() |
| 17 | 17 | { |
| 18 | 18 | $abstract = $this->newInstance(); |
| 19 | - $getBaseUrlCaller = function () { |
|
| 19 | + $getBaseUrlCaller = function() { |
|
| 20 | 20 | return $this->getBaseUrl(); |
| 21 | 21 | }; |
| 22 | 22 | $abstract->domain = 'domain'; |
@@ -28,16 +28,16 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | $abstract = $this->newInstance(); |
| 30 | 30 | $abstract->setApiKey('123456val'); |
| 31 | - $apiKeyValCaller = function () { |
|
| 31 | + $apiKeyValCaller = function() { |
|
| 32 | 32 | return $this->apiKey; |
| 33 | 33 | }; |
| 34 | 34 | $bound = $apiKeyValCaller->bindTo($abstract, $abstract); |
| 35 | 35 | $this->assertEquals('123456val', $bound()); |
| 36 | 36 | |
| 37 | - $abstract->setApiKey(function () { |
|
| 38 | - return '123456'.'fun'; |
|
| 37 | + $abstract->setApiKey(function() { |
|
| 38 | + return '123456' . 'fun'; |
|
| 39 | 39 | }); |
| 40 | - $apiKeyFunCaller = function () { |
|
| 40 | + $apiKeyFunCaller = function() { |
|
| 41 | 41 | return $this->apiKey; |
| 42 | 42 | }; |
| 43 | 43 | $bound = $apiKeyFunCaller->bindTo($abstract, $abstract); |
@@ -47,12 +47,12 @@ discard block |
||
| 47 | 47 | public function testGetActionUrl() |
| 48 | 48 | { |
| 49 | 49 | $abstract = $this->newInstance(); |
| 50 | - $getBaseUrlGetCodeCaller = function () { |
|
| 50 | + $getBaseUrlGetCodeCaller = function() { |
|
| 51 | 51 | $this->captchaId = 123; |
| 52 | 52 | |
| 53 | 53 | return $this->getActionUrl('get_code'); |
| 54 | 54 | }; |
| 55 | - $getBaseUrlGetBalanceCaller = function () { |
|
| 55 | + $getBaseUrlGetBalanceCaller = function() { |
|
| 56 | 56 | $this->captchaId = 234; |
| 57 | 57 | |
| 58 | 58 | return $this->getActionUrl('get_balance'); |
@@ -68,13 +68,13 @@ discard block |
||
| 68 | 68 | public function testGetFilePath() |
| 69 | 69 | { |
| 70 | 70 | $abstract = $this->newInstance(); |
| 71 | - $getFilePathCaller = function ($val) { |
|
| 71 | + $getFilePathCaller = function($val) { |
|
| 72 | 72 | return $this->getFilePath($val); |
| 73 | 73 | }; |
| 74 | 74 | $bound = $getFilePathCaller->bindTo($abstract, $abstract); |
| 75 | - $this->assertEquals(__DIR__.'/data/Captcha.jpg', $bound(__DIR__.'/data/Captcha.jpg')); |
|
| 75 | + $this->assertEquals(__DIR__ . '/data/Captcha.jpg', $bound(__DIR__ . '/data/Captcha.jpg')); |
|
| 76 | 76 | $filePathUpload = $bound('https://upload.wikimedia.org/wikipedia/commons/6/69/Captcha.jpg'); |
| 77 | - $file1 = file_get_contents(__DIR__.'/data/Captcha.jpg'); |
|
| 77 | + $file1 = file_get_contents(__DIR__ . '/data/Captcha.jpg'); |
|
| 78 | 78 | $file2 = file_get_contents($filePathUpload); |
| 79 | 79 | $this->assertEquals($file1, $file2); |
| 80 | 80 | } |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | public function testGetFilePathErrorFileNotFound() |
| 87 | 87 | { |
| 88 | 88 | $abstract = $this->newInstance(); |
| 89 | - $getFilePathCaller = function ($val) { |
|
| 89 | + $getFilePathCaller = function($val) { |
|
| 90 | 90 | return $this->getFilePath($val); |
| 91 | 91 | }; |
| 92 | 92 | $bound = $getFilePathCaller->bindTo($abstract, $abstract); |
| 93 | - $bound(__DIR__.'/data/Captcha1.jpg'); |
|
| 93 | + $bound(__DIR__ . '/data/Captcha1.jpg'); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | public function testGetFilePathErrorFileIsNotLoaded() |
| 102 | 102 | { |
| 103 | 103 | $abstract = $this->newInstance(); |
| 104 | - $getFilePathCaller = function ($val) { |
|
| 104 | + $getFilePathCaller = function($val) { |
|
| 105 | 105 | return $this->getFilePath($val); |
| 106 | 106 | }; |
| 107 | 107 | $bound = $getFilePathCaller->bindTo($abstract, $abstract); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | { |
| 113 | 113 | $abstract = $this->newInstance(); |
| 114 | 114 | $abstract->domain = 'echo.jsontest.com/aaa/bbb'; |
| 115 | - $getResponseCaller = function ($val) { |
|
| 115 | + $getResponseCaller = function($val) { |
|
| 116 | 116 | return $this->getResponse($val); |
| 117 | 117 | }; |
| 118 | 118 | $bound = $getResponseCaller->bindTo($abstract, $abstract); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | public function testExecutionDelayed() |
| 124 | 124 | { |
| 125 | 125 | $abstract = $this->newInstance(); |
| 126 | - $executionDelayedCaller = function ($second, $call = null) { |
|
| 126 | + $executionDelayedCaller = function($second, $call = null) { |
|
| 127 | 127 | return $this->executionDelayed($second, $call); |
| 128 | 128 | }; |
| 129 | 129 | $bound = $executionDelayedCaller->bindTo($abstract, $abstract); |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | $this->assertTrue(abs($timePassed - 0.1) < 0.035); |
| 135 | 135 | |
| 136 | 136 | $start = microtime(true); |
| 137 | - $bound(0.15, function () { |
|
| 137 | + $bound(0.15, function() { |
|
| 138 | 138 | sleep(0.2); |
| 139 | 139 | }); |
| 140 | 140 | $bound(0.1); |
@@ -142,14 +142,14 @@ discard block |
||
| 142 | 142 | $this->assertTrue(abs($timePassed - 0.25) < 0.035); |
| 143 | 143 | |
| 144 | 144 | $start = microtime(true); |
| 145 | - $bound(0.15, function () { |
|
| 145 | + $bound(0.15, function() { |
|
| 146 | 146 | sleep(0.2); |
| 147 | 147 | }); |
| 148 | 148 | $bound(0.3); |
| 149 | 149 | $timePassed = microtime(true) - $start; |
| 150 | 150 | $this->assertTrue(abs($timePassed - 0.45) < 0.035); |
| 151 | 151 | |
| 152 | - $this->assertEquals(2, $bound(0, function () { |
|
| 152 | + $this->assertEquals(2, $bound(0, function() { |
|
| 153 | 153 | return 2; |
| 154 | 154 | })); |
| 155 | 155 | $this->assertEquals(null, $bound(0)); |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | public function testGetInUrl() |
| 159 | 159 | { |
| 160 | 160 | $abstract = $this->newInstance(); |
| 161 | - $getInUrlCaller = function () { |
|
| 161 | + $getInUrlCaller = function() { |
|
| 162 | 162 | return $this->getInUrl(); |
| 163 | 163 | }; |
| 164 | 164 | $abstract->domain = 'domain'; |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | public function testIsError() |
| 175 | 175 | { |
| 176 | 176 | $abstract = $this->newInstance(); |
| 177 | - $isErrorCaller = function ($val) { |
|
| 177 | + $isErrorCaller = function($val) { |
|
| 178 | 178 | return $this->isError($val); |
| 179 | 179 | }; |
| 180 | 180 | $bound = $isErrorCaller->bindTo($abstract, $abstract); |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | public function testIsErrorNot() |
| 185 | 185 | { |
| 186 | 186 | $abstract = $this->newInstance(); |
| 187 | - $isErrorCaller = function ($val) { |
|
| 187 | + $isErrorCaller = function($val) { |
|
| 188 | 188 | return $this->isError($val); |
| 189 | 189 | }; |
| 190 | 190 | $bound = $isErrorCaller->bindTo($abstract, $abstract); |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | { |
| 201 | 201 | $abstract = $this->newInstance(); |
| 202 | 202 | $abstract->domain = 'domain'; |
| 203 | - $getCurlResponseCaller = function ($val) { |
|
| 203 | + $getCurlResponseCaller = function($val) { |
|
| 204 | 204 | return $this->getCurlResponse($val); |
| 205 | 205 | }; |
| 206 | 206 | $bound = $getCurlResponseCaller->bindTo($abstract, $abstract); |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | { |
| 212 | 212 | $abstract = $this->newInstance(); |
| 213 | 213 | $abstract->domain = 'httpbin.org'; |
| 214 | - $getCurlResponseCaller = function ($val) { |
|
| 214 | + $getCurlResponseCaller = function($val) { |
|
| 215 | 215 | $this->inUrl = 'post'; |
| 216 | 216 | |
| 217 | 217 | return $this->getCurlResponse($val); |
@@ -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, |
@@ -121,7 +121,7 @@ |
||
| 121 | 121 | */ |
| 122 | 122 | protected function getInUrl() |
| 123 | 123 | { |
| 124 | - return $this->getBaseUrl().$this->inUrl; |
|
| 124 | + return $this->getBaseUrl() . $this->inUrl; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -99,29 +99,29 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | protected $params = []; |
| 101 | 101 | |
| 102 | - protected function getParams(){ |
|
| 102 | + protected function getParams() { |
|
| 103 | 103 | $params = []; |
| 104 | 104 | foreach ($this->paramsSettings as $field => $settings) { |
| 105 | 105 | $value = null; |
| 106 | 106 | if (array_key_exists($field, $this->params) && (!array_key_exists(self::PARAM_SLUG_VARIABLE, $settings) ^ (array_key_exists(self::PARAM_SLUG_VARIABLE, $settings) && $settings[self::PARAM_SLUG_VARIABLE] === false))) { |
| 107 | 107 | $value = $this->params[$field]; |
| 108 | 108 | } |
| 109 | - if(array_key_exists(self::PARAM_SLUG_DEFAULT, $settings)) { |
|
| 109 | + if (array_key_exists(self::PARAM_SLUG_DEFAULT, $settings)) { |
|
| 110 | 110 | $value = $settings[self::PARAM_SLUG_DEFAULT]; |
| 111 | 111 | } |
| 112 | - if(array_key_exists(self::PARAM_SLUG_SPEC, $settings) && array_key_exists($settings[self::PARAM_SLUG_SPEC], $this->paramsSpec)) { |
|
| 112 | + if (array_key_exists(self::PARAM_SLUG_SPEC, $settings) && array_key_exists($settings[self::PARAM_SLUG_SPEC], $this->paramsSpec)) { |
|
| 113 | 113 | $value = $this->paramsSpec[$settings[self::PARAM_SLUG_SPEC]]; |
| 114 | 114 | } |
| 115 | - if(array_key_exists(self::PARAM_SLUG_REQUIRE, $settings) && $settings[self::PARAM_SLUG_REQUIRE] === true && is_null($value)) { |
|
| 115 | + if (array_key_exists(self::PARAM_SLUG_REQUIRE, $settings) && $settings[self::PARAM_SLUG_REQUIRE] === true && is_null($value)) { |
|
| 116 | 116 | throw new Exception('Нет данных'); |
| 117 | 117 | } |
| 118 | - if(array_key_exists($field, $this->paramsNames)) { |
|
| 118 | + if (array_key_exists($field, $this->paramsNames)) { |
|
| 119 | 119 | switch ($settings[self::PARAM_SLUG_TYPE]) { |
| 120 | 120 | case self::PARAM_FIELD_TYPE_INTEGER: |
| 121 | - $params[$this->paramsNames[$field]] = (int)$value; |
|
| 121 | + $params[$this->paramsNames[$field]] = (int) $value; |
|
| 122 | 122 | break; |
| 123 | 123 | case self::PARAM_FIELD_TYPE_STRING: |
| 124 | - $params[$this->paramsNames[$field]] = (string)$value; |
|
| 124 | + $params[$this->paramsNames[$field]] = (string) $value; |
|
| 125 | 125 | break; |
| 126 | 126 | } |
| 127 | 127 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | return [ |
| 204 | 204 | 'method' => 'post', |
| 205 | 205 | 'key' => $this->apiKey, |
| 206 | - 'file' => (version_compare(PHP_VERSION, '5.5.0') >= 0) ? new \CURLFile($filePath) : '@'.$filePath, |
|
| 206 | + 'file' => (version_compare(PHP_VERSION, '5.5.0') >= 0) ? new \CURLFile($filePath) : '@' . $filePath, |
|
| 207 | 207 | 'phrase' => $this->isPhrase, |
| 208 | 208 | 'regsense' => $this->isRegSense, |
| 209 | 209 | 'numeric' => $this->isNumeric, |