Passed
Push — develop ( 391f8f...187ad6 )
by Paul
13:53
created

PermissionValidator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 6
dl 0
loc 14
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 6 2
A performValidation() 0 4 2
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Modules\Validator;
4
5
class PermissionValidator extends ValidatorAbstract
6
{
7 1
    public function isValid(): bool
8
    {
9 1
        if (glsr_get_option('general.require.login', false, 'bool')) {
10 1
            return is_user_logged_in();
11
        }
12 1
        return true;
13
    }
14
15 1
    public function performValidation(): void
16
    {
17 1
        if (!$this->isValid()) {
18 1
            $this->fail(__('You must be logged in to submit a review.', 'site-reviews'));
19
        }
20
    }
21
}
22