Test Failed
Push — develop ( 425fc0...4f2be8 )
by Paul
13:11
created

HoneypotValidator::performValidation()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Modules\Validator;
4
5
use GeminiLabs\SiteReviews\Modules\Honeypot;
6
7
class HoneypotValidator extends ValidatorAbstract
8
{
9 1
    public function isValid(): bool
10
    {
11 1
        $hash = glsr(Honeypot::class)->hash($this->request->form_id);
12 1
        $isValid = isset($this->request[$hash]) && empty($this->request[$hash]);
13 1
        return glsr()->filterBool('validate/honeypot', $isValid, $this->request);
14
    }
15
16 1
    public function performValidation(): void
17
    {
18 1
        if (!$this->isValid()) {
19 1
            $this->fail(
20 1
                __('This review has been flagged as possible spam and cannot be submitted.', 'site-reviews'),
21 1
                'The Honeypot caught a bad submission.'
22 1
            );
23
        }
24
    }
25
}
26