Code Duplication    Length = 18-18 lines in 2 locations

src/services/Rucaptcha.php 1 location

@@ 49-66 (lines=18) @@
46
            list(, $this->captchaId) = explode('|', $result);
47
            $waitTime = 0;
48
            sleep($this->requestTimeout);
49
            while (true) {
50
                $result = $this->getResponse('get');
51
                $this->setError($result);
52
                if ($result == 'CAPCHA_NOT_READY') {
53
                    $waitTime += $this->requestTimeout;
54
                    if ($waitTime > $this->maxTimeout) {
55
                        break;
56
                    }
57
                    sleep($this->requestTimeout);
58
                } else {
59
                    $ex = explode('|', $result);
60
                    if (trim($ex[0]) == 'OK') {
61
                        $this->result = trim($ex[1]);
62
63
                        return true;
64
                    }
65
                }
66
            }
67
            throw new Exception('Лимит времени превышен');
68
        } catch (Exception $e) {
69
            $this->error = $e->getMessage();

src/core/DeCaptchaBase.php 1 location

@@ 172-189 (lines=18) @@
169
            list(, $this->captchaId) = explode('|', $result);
170
            $waitTime = 0;
171
            sleep($this->requestTimeout);
172
            while (true) {
173
                $result = $this->getResponse('get');
174
                $this->setError($result);
175
                if ($result == 'CAPCHA_NOT_READY') {
176
                    $waitTime += $this->requestTimeout;
177
                    if ($waitTime > $this->maxTimeout) {
178
                        break;
179
                    }
180
                    sleep($this->requestTimeout);
181
                } else {
182
                    $ex = explode('|', $result);
183
                    if (trim($ex[0]) == 'OK') {
184
                        $this->result = trim($ex[1]);
185
186
                        return true;
187
                    }
188
                }
189
            }
190
            throw new Exception('Лимит времени превышен');
191
        } catch (Exception $e) {
192
            $this->error = $e->getMessage();