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

PermissionValidator::performValidation()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Modules\Validator;
4
5
use GeminiLabs\SiteReviews\Helpers\Cast;
6
7
class PermissionValidator extends ValidatorAbstract
8
{
9
    /**
10
     * @return bool
11
     */
12
    public function isValid()
13
    {
14
        if (Cast::toBool(glsr_get_option('general.require.login'))) {
15
            return is_user_logged_in();
16
        }
17
        return true;
18
    }
19
20
    /**
21
     * @return void
22
     */
23
    public function performValidation()
24
    {
25
        if (!$this->isValid()) {
26
            $this->setErrors(__('You must be logged in to submit a review.', 'site-reviews'));
27
        }
28
    }
29
}
30