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

PermissionValidator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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