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

CustomValidator::performValidation()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
nc 3
nop 0
dl 0
loc 10
ccs 7
cts 7
cp 1
crap 3
rs 10
c 1
b 0
f 0
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