Token::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Tymon\JWTAuth;
4
5
use Tymon\JWTAuth\Validators\TokenValidator;
6
7
class Token
8
{
9
    /**
10
     * @var string
11
     */
12
    private $value;
13
14
    /**
15
     * Create a new JSON Web Token
16
     *
17
     * @param string  $value
18
     */
19 51
    public function __construct($value)
20
    {
21 51
        with(new TokenValidator)->check($value);
22
23 51
        $this->value = $value;
24 51
    }
25
26
    /**
27
     * Get the token
28
     *
29
     * @return string
30
     */
31 15
    public function get()
32
    {
33 15
        return $this->value;
34
    }
35
36
    /**
37
     * Get the token when casting to string
38
     *
39
     * @return string
40
     */
41 21
    public function __toString()
42
    {
43 21
        return (string) $this->value;
44
    }
45
}
46