Test Failed
Push — master ( 31c635...ef6440 )
by Paul
07:17 queued 01:32
created

HoneypotValidator::isValid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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