HmacToken   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 49
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCredentials() 0 3 1
A getRequest() 0 3 1
A __construct() 0 6 1
1
<?php
2
3
namespace Acquia\Hmac\Symfony;
4
5
use Acquia\Hmac\KeyInterface;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;
8
9
/**
10
 * An authentication token for HTTP HMAC requests.
11
 */
12
class HmacToken extends AbstractToken
13
{
14
    /**
15
     * @var \Symfony\Component\HttpFoundation\Request
16
     *   The authenticated request.
17
     */
18
    protected $request;
19
20
    /**
21
     * @var \Acquia\Hmac\KeyInterface
22
     *   The authenticated credentials.
23
     */
24
    protected $key;
25
26
    /**
27
     * Initializes the token.
28
     *
29
     * @param \Symfony\Component\HttpFoundation\Request $request
30
     *   The authenticated request.
31
     * @param \Acquia\Hmac\KeyInterface $key
32
     *   An optional set of authenticated credentials.
33
     * @param \Symfony\Component\Security\Core\Role\RoleInterface[]|string[] $roles
34
     *   An array of roles.
35
     */
36 6
    public function __construct(Request $request, KeyInterface $key = null, array $roles = [])
37
    {
38 6
        parent::__construct($roles);
39
40 6
        $this->request = $request;
41 6
        $this->key = $key;
42 6
    }
43
44
    /**
45
     * Returns the authenticated request associated with the token.
46
     *
47
     * @return \Symfony\Component\HttpFoundation\Request
48
     *   The authenticated request.
49
     */
50 3
    public function getRequest()
51
    {
52 3
        return $this->request;
53
    }
54
55
    /**
56
     * {@inheritDoc}
57
     */
58 3
    public function getCredentials()
59
    {
60 3
        return $this->key;
61
    }
62
}
63