Passed
Push — develop ( c34e50...445d6d )
by Paul
06:42
created

PermissionValidator::isValid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
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
class PermissionValidator extends ValidatorAbstract
6
{
7
    public function isValid(): bool
8
    {
9
        if (glsr_get_option('general.require.login', false, 'bool')) {
10
            return is_user_logged_in();
11
        }
12
        return true;
13
    }
14
15
    public function performValidation(): void
16
    {
17
        if (!$this->isValid()) {
18
            $this->fail(__('You must be logged in to submit a review.', 'site-reviews'));
19
        }
20
    }
21
}
22