Passed
Push — master ( 6f7c4e...f6c223 )
by Paul
15:42 queued 07:15
created

CustomValidator::isValid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Modules\Validator;
4
5
use GeminiLabs\SiteReviews\Helpers\Cast;
6
7
class CustomValidator extends ValidatorAbstract
8
{
9
    /**
10
     * @return bool
11
     */
12
    public function isValid()
13
    {
14
        return Cast::toBool(glsr()->filter('validate/custom', true, $this->request));
15
    }
16
17
    /**
18
     * @return void
19
     */
20 1
    public function performValidation()
21
    {
22 1
        $validated = glsr()->filter('validate/custom', true, $this->request); // value may be a string
23 1
        if (true === Cast::toBool($validated)) {
24 1
            return;
25
        }
26 1
        if (!is_string($validated)) {
27 1
            $validated = __('The review submission failed. Please notify the site administrator.', 'site-reviews');
28
        }
29 1
        $this->setErrors($validated);
30 1
    }
31
}
32