JWSCreator::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 5
rs 10
1
<?php
2
/*
3
 * This file is part of the Guarded Authentication package.
4
 *
5
 * (c) Jafar Jabr <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Jafar\Bundle\GuardedAuthenticationBundle\Api\JWSCreator;
12
13
/**
14
 * Class JWSCreator.
15
 *
16
 * @author Jafar Jabr <[email protected]>
17
 */
18
class JWSCreator implements JWSCreatorInterface
19
{
20
    const SIGNED = 'signed';
21
22
    /**
23
     * The JSON Web Token.
24
     *
25
     * @var string
26
     */
27
    private $token;
28
29
    /**
30
     * @var string
31
     */
32
    private $state;
33
34
    /**
35
     * JWSCreator constructor.
36
     *
37
     * @param string $token
38
     * @param bool   $isSigned
39
     */
40
    public function __construct(string $token, bool $isSigned)
41
    {
42
        $this->token = $token;
43
        if (true === $isSigned) {
44
            $this->state = self::SIGNED;
45
        }
46
    }
47
48
    /**
49
     * @return bool
50
     */
51
    public function isSigned()
52
    {
53
        return self::SIGNED === $this->state;
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function getToken()
60
    {
61
        return $this->token;
62
    }
63
}
64