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

@@ 129-146 (lines=18) @@
126
            list(, $this->captchaId) = explode('|', $result);
127
            $waitTime = 0;
128
            sleep($this->requestTimeout);
129
            while (true) {
130
                $result = $this->getResponse('get');
131
                $this->setError($result);
132
                if ($result == 'CAPCHA_NOT_READY') {
133
                    $waitTime += $this->requestTimeout;
134
                    if ($waitTime > $this->maxTimeout) {
135
                        break;
136
                    }
137
                    sleep($this->requestTimeout);
138
                } else {
139
                    $ex = explode('|', $result);
140
                    if (trim($ex[0]) == 'OK') {
141
                        $this->result = trim($ex[1]);
142
143
                        return true;
144
                    }
145
                }
146
            }
147
            throw new Exception('Лимит времени превышен');
148
        } catch (Exception $e) {
149
            $this->error = $e->getMessage();