| Total Complexity | 15 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | abstract class ACaptcha extends AControl |
||
| 17 | { |
||
| 18 | protected ?ITimeout $libTimeout = null; |
||
| 19 | |||
| 20 | 1 | public function addRules(/** @scrutinizer ignore-unused */ iterable $rules = []): void |
|
| 21 | { |
||
| 22 | // no adding external rules applicable |
||
| 23 | 1 | } |
|
| 24 | |||
| 25 | 2 | public function getRules(): array |
|
| 26 | { |
||
| 27 | 2 | $ruleset = $this->canPass() ? [] : $this->rules; |
|
| 28 | 2 | if ($this->libTimeout && !empty($ruleset)) { |
|
| 29 | 1 | $this->libTimeout->updateExpire(); |
|
| 30 | } |
||
| 31 | 2 | return $ruleset; |
|
| 32 | } |
||
| 33 | |||
| 34 | 1 | public function removeRules(): void |
|
| 35 | { |
||
| 36 | // no rules removal applicable |
||
| 37 | 1 | } |
|
| 38 | |||
| 39 | 1 | public function renderLabel($attributes = []): string |
|
| 40 | { |
||
| 41 | 1 | return $this->canPass() ? '' : parent::renderLabel($attributes); |
|
| 42 | } |
||
| 43 | |||
| 44 | 1 | public function renderInput($attributes = []): string |
|
| 45 | { |
||
| 46 | 1 | return $this->canPass() ? '' : parent::renderInput($attributes); |
|
| 47 | } |
||
| 48 | |||
| 49 | 1 | public function renderErrors(array $errors): string |
|
| 52 | } |
||
| 53 | |||
| 54 | 2 | protected function canPass(): bool |
|
| 55 | { |
||
| 56 | 2 | return ($this->libTimeout && $this->libTimeout->isRunning()); |
|
| 57 | } |
||
| 58 | |||
| 59 | 7 | public function setTimeout(?ITimeout $libTimeout = null): self |
|
| 63 | } |
||
| 64 | } |
||
| 65 |