AbstractValidator::isValid()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4286
cc 2
eloc 6
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Tymon\JWTAuth\Validators;
4
5
use Tymon\JWTAuth\Exceptions\JWTException;
6
7
abstract class AbstractValidator implements ValidatorInterface
8
{
9
    /**
10
     * @var bool
11
     */
12
    protected $refreshFlow = false;
13
14
    /**
15
     * Helper function to return a boolean
16
     *
17
     * @param  array  $value
18
     * @return bool
19
     */
20 9
    public function isValid($value)
21
    {
22
        try {
23 9
            $this->check($value);
24 7
        } catch (JWTException $e) {
25 3
            return false;
26
        }
27
28 6
        return true;
29
    }
30
31
    /**
32
     * Set the refresh flow flag
33
     *
34
     * @param  bool  $refreshFlow
35
     * @return $this
36
     */
37
    public function setRefreshFlow($refreshFlow = true)
38
    {
39
        $this->refreshFlow = $refreshFlow;
40
41
        return $this;
42
    }
43
}
44