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

PermissionValidator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
eloc 6
dl 0
loc 14
ccs 0
cts 7
cp 0
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
    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