TokenValidator::validateStructure()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4286
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Tymon\JWTAuth\Validators;
4
5
use Tymon\JWTAuth\Exceptions\TokenInvalidException;
6
7
class TokenValidator extends AbstractValidator
8
{
9
    /**
10
     * Check the structure of the token
11
     *
12
     * @param string  $value
13
     * @return void
14
     */
15 60
    public function check($value)
16
    {
17 60
        $this->validateStructure($value);
18 54
    }
19
20
    /**
21
     * @param  string  $token
22
     * @throws \Tymon\JWTAuth\Exceptions\TokenInvalidException
23
     * @return boolean
24
     */
25 60
    protected function validateStructure($token)
26
    {
27 60
        if (count(explode('.', $token)) !== 3) {
28 6
            throw new TokenInvalidException('Wrong number of segments');
29
        }
30
31 54
        return true;
32
    }
33
}
34