Completed
Push — master ( 599dfd...0e29c2 )
by Владислав
02:23
created
tests/TwoCaptchaTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
         ]);
18 18
         $captcha->setErrorLang(\jumper423\decaptcha\core\DeCaptchaErrors::LANG_RU);
19 19
         $captcha->setCauseAnError(true);
20
-        $captcha->recognize(__DIR__.'/data/Captcha.jpg');
20
+        $captcha->recognize(__DIR__ . '/data/Captcha.jpg');
21 21
     }
22 22
 
23 23
     public function testRecognizeBalanceError2()
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
             \jumper423\decaptcha\services\TwoCaptcha::PARAM_SPEC_API_KEY => '200a1ed2b6ca001d8171c655658086ed',
27 27
         ]);
28 28
         $captcha->setErrorLang(\jumper423\decaptcha\core\DeCaptchaErrors::LANG_RU);
29
-        if ($captcha->recognize(__DIR__.'/data/Captcha.jpg')) {
29
+        if ($captcha->recognize(__DIR__ . '/data/Captcha.jpg')) {
30 30
             $this->assertEquals('11111111111111', $captcha->getCode());
31 31
         } else {
32 32
             $this->assertEquals('Нулевой либо отрицательный баланс', $captcha->getError());
Please login to merge, or discard this patch.
src/core/DeCaptchaAbstract.php 1 patch
Spacing   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -93,8 +93,7 @@  discard block
 block discarded – undo
93 93
         }
94 94
         $decodeSetting = $this->decodeSettings[static::DECODE_ACTION][$action];
95 95
         $decodeFormat = array_key_exists(static::DECODE_FORMAT, $decodeSetting) ?
96
-            $decodeSetting[static::DECODE_FORMAT] :
97
-            $this->decodeSettings[static::DECODE_FORMAT];
96
+            $decodeSetting[static::DECODE_FORMAT] : $this->decodeSettings[static::DECODE_FORMAT];
98 97
         $values = [];
99 98
         switch ($decodeFormat) {
100 99
             case static::RESPONSE_TYPE_STRING:
@@ -155,7 +154,7 @@  discard block
 block discarded – undo
155 154
      */
156 155
     protected function getActionUrl($action)
157 156
     {
158
-        return $this->getBaseUrl().$this->actions[$action][static::ACTION_URI];
157
+        return $this->getBaseUrl() . $this->actions[$action][static::ACTION_URI];
159 158
     }
160 159
 
161 160
     /**
@@ -199,7 +198,7 @@  discard block
 block discarded – undo
199 198
         }
200 199
         switch ($param) {
201 200
             case static::PARAM_SPEC_FILE:
202
-                return (version_compare(PHP_VERSION, '5.5.0') >= 0) ? new \CURLFile($this->getFilePath($this->params[$param])) : '@'.$this->getFilePath($this->params[$param]);
201
+                return (version_compare(PHP_VERSION, '5.5.0') >= 0) ? new \CURLFile($this->getFilePath($this->params[$param])) : '@' . $this->getFilePath($this->params[$param]);
203 202
             case static::PARAM_SPEC_API_KEY:
204 203
                 return is_callable($this->params[$param]) ? $this->params[$param]() : $this->params[$param];
205 204
             case static::PARAM_SPEC_CAPTCHA:
@@ -309,7 +308,7 @@  discard block
 block discarded – undo
309 308
             foreach ($data as $key => $value) {
310 309
                 $uri[] = "$key=$value";
311 310
             }
312
-            $url .= '?'.implode('&', $uri);
311
+            $url .= '?' . implode('&', $uri);
313 312
         }
314 313
         curl_setopt($ch, CURLOPT_URL, $url);
315 314
         if (!$isJson && version_compare(PHP_VERSION, '5.5.0') >= 0 && version_compare(PHP_VERSION, '7.0') < 0 && defined('CURLOPT_SAFE_UPLOAD')) {
@@ -327,7 +326,7 @@  discard block
 block discarded – undo
327 326
             curl_setopt($ch, CURLOPT_HTTPHEADER, [
328 327
                 'Content-Type: application/json; charset=utf-8',
329 328
                 'Accept: application/json',
330
-                'Content-Length: '.strlen($data),
329
+                'Content-Length: ' . strlen($data),
331 330
             ]);
332 331
         }
333 332
         $result = curl_exec($ch);
Please login to merge, or discard this patch.
tests/AnticaptchaTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
             \jumper423\decaptcha\services\Anticaptcha::PARAM_SPEC_API_KEY => '5464654645646',
12 12
         ]);
13 13
         $captcha->setErrorLang(\jumper423\decaptcha\core\DeCaptchaErrors::LANG_RU);
14
-        if ($captcha->recognize(__DIR__.'/data/Captcha.jpg')) {
14
+        if ($captcha->recognize(__DIR__ . '/data/Captcha.jpg')) {
15 15
             $this->assertEquals('11111111111111', $captcha->getCode());
16 16
         } else {
17 17
             $this->assertEquals('Нулевой либо отрицательный баланс', $captcha->getError());
Please login to merge, or discard this patch.
tests/DeCaptchaAbstractTest.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     public function testGetBaseUrl()
20 20
     {
21 21
         $abstract = $this->newInstance();
22
-        $getBaseUrlCaller = function () {
22
+        $getBaseUrlCaller = function() {
23 23
             $this->host = 'domain';
24 24
 
25 25
             return $this->getBaseUrl();
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         $this->assertEquals('http://domain/', $bound());
29 29
 
30 30
         $abstract = $this->newInstance();
31
-        $getBaseUrlCaller = function () {
31
+        $getBaseUrlCaller = function() {
32 32
             $this->host = 'domain';
33 33
             $this->scheme = 'https';
34 34
 
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
     public function testGetFilePath()
63 63
     {
64 64
         $abstract = $this->newInstance();
65
-        $getFilePathCaller = function ($val) {
65
+        $getFilePathCaller = function($val) {
66 66
             return $this->getFilePath($val);
67 67
         };
68 68
         $bound = $getFilePathCaller->bindTo($abstract, $abstract);
69
-        $this->assertEquals(__DIR__.'/data/Captcha.jpg', $bound(__DIR__.'/data/Captcha.jpg'));
69
+        $this->assertEquals(__DIR__ . '/data/Captcha.jpg', $bound(__DIR__ . '/data/Captcha.jpg'));
70 70
         $filePathUpload = $bound('https://upload.wikimedia.org/wikipedia/commons/6/69/Captcha.jpg');
71
-        $file1 = file_get_contents(__DIR__.'/data/Captcha.jpg');
71
+        $file1 = file_get_contents(__DIR__ . '/data/Captcha.jpg');
72 72
         $file2 = file_get_contents($filePathUpload);
73 73
         $this->assertEquals($file1, $file2);
74 74
     }
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
     public function testGetFilePathErrorFileNotFound()
81 81
     {
82 82
         $abstract = $this->newInstance();
83
-        $getFilePathCaller = function ($val) {
83
+        $getFilePathCaller = function($val) {
84 84
             return $this->getFilePath($val);
85 85
         };
86 86
         $bound = $getFilePathCaller->bindTo($abstract, $abstract);
87
-        $bound(__DIR__.'/data/Captcha1.jpg');
87
+        $bound(__DIR__ . '/data/Captcha1.jpg');
88 88
     }
89 89
 
90 90
     /**
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     public function testGetFilePathErrorFileIsNotLoaded()
96 96
     {
97 97
         $abstract = $this->newInstance();
98
-        $getFilePathCaller = function ($val) {
98
+        $getFilePathCaller = function($val) {
99 99
             return $this->getFilePath($val);
100 100
         };
101 101
         $bound = $getFilePathCaller->bindTo($abstract, $abstract);
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     public function testExecutionDelayed()
118 118
     {
119 119
         $abstract = $this->newInstance();
120
-        $executionDelayedCaller = function ($second, $call = null) {
120
+        $executionDelayedCaller = function($second, $call = null) {
121 121
             return $this->executionDelayed($second, $call);
122 122
         };
123 123
         $bound = $executionDelayedCaller->bindTo($abstract, $abstract);
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         $this->assertTrue(abs($timePassed - 0.1) < 0.035);
129 129
 
130 130
         $start = microtime(true);
131
-        $bound(0.15, function () {
131
+        $bound(0.15, function() {
132 132
             sleep(0.2);
133 133
         });
134 134
         $bound(0.1);
@@ -136,14 +136,14 @@  discard block
 block discarded – undo
136 136
         $this->assertTrue(abs($timePassed - 0.25) < 0.035);
137 137
 
138 138
         $start = microtime(true);
139
-        $bound(0.15, function () {
139
+        $bound(0.15, function() {
140 140
             sleep(0.2);
141 141
         });
142 142
         $bound(0.3);
143 143
         $timePassed = microtime(true) - $start;
144 144
         $this->assertTrue(abs($timePassed - 0.45) < 0.035);
145 145
 
146
-        $this->assertEquals(2, $bound(0, function () {
146
+        $this->assertEquals(2, $bound(0, function() {
147 147
             return 2;
148 148
         }));
149 149
         $this->assertEquals(null, $bound(0));
Please login to merge, or discard this patch.
src/core/DeCaptchaWiki.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 class DeCaptchaWiki
11 11
 {
12
-    public function view(){
12
+    public function view() {
13 13
         $rucaptcha = new RuCaptcha([]);
14 14
         /*
15 15
          * Markdown | Less | Pretty
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
             }
29 29
             echo " {$this->ggg($rr, 'ACTION_FIELD_', $param)} |";
30 30
             echo " {$this->ggg($rr, 'ACTION_FIELD_', $param)} |";
31
-            echo " ".substr($this->ggg($rr, 'PARAM_FIELD_TYPE_', $setting[RuCaptcha::PARAM_SLUG_TYPE]), 17) ." |";
32
-            echo " ".(array_key_exists(RuCaptcha::PARAM_SLUG_REQUIRE, $setting) ? '+' : '-') ." |";
33
-            echo " ".(array_key_exists(RuCaptcha::PARAM_SLUG_DEFAULT, $setting) ? $setting[RuCaptcha::PARAM_SLUG_DEFAULT] : '') ." |";
31
+            echo " " . substr($this->ggg($rr, 'PARAM_FIELD_TYPE_', $setting[RuCaptcha::PARAM_SLUG_TYPE]), 17) . " |";
32
+            echo " " . (array_key_exists(RuCaptcha::PARAM_SLUG_REQUIRE, $setting) ? '+' : '-') . " |";
33
+            echo " " . (array_key_exists(RuCaptcha::PARAM_SLUG_DEFAULT, $setting) ? $setting[RuCaptcha::PARAM_SLUG_DEFAULT] : '') . " |";
34 34
             echo " |";
35
-            echo " ". PHP_EOL;
35
+            echo " " . PHP_EOL;
36 36
 //            echo " --- | --- | --- | --- | ---| --- " . PHP_EOL;
37 37
 //            print_r($params);
38 38
         }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 //        file_put_contents(__DIR__ . '/12331123', json_encode(get_defined_constants(true)));
43 43
     }
44 44
 
45
-    public function ggg($constants, $keyMask, $value){
45
+    public function ggg($constants, $keyMask, $value) {
46 46
         foreach ($constants as $key => $val) {
47 47
             if (stripos($key, $keyMask) !== false && $val === $value) {
48 48
                 return $key;
Please login to merge, or discard this patch.