Passed
Push — master ( fd01cd...a8d522 )
by Alexandre
02:26
created

AuthorizationCode::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 7
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
ccs 7
cts 7
cp 1
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Alexandre
5
 * Date: 07/03/2018
6
 * Time: 21:57
7
 */
8
9
namespace OAuth2\Credentials;
10
11
class AuthorizationCode implements AuthorizationCodeInterface
12
{
13
    /**
14
     * @var string
15
     */
16
    protected $code;
17
    /**
18
     * @var string
19
     */
20
    protected $scope;
21
    /**
22
     * @var string
23
     */
24
    protected $clientIdentifier;
25
    /**
26
     * @var string
27
     */
28
    protected $resourceOwnerIdentifier;
29
    /**
30
     * @var string|null
31
     */
32
    protected $requestedScope;
33
    /**
34
     * @var string|null
35
     */
36
    protected $redirectUri;
37
    /**
38
     * @var int
39
     */
40
    protected $expiresAt;
41
42
    public function __construct(string $code, string $scope, string $clientIdentifier, string $resourceOwnerIdentifier,
43 2
                                int $expiresAt, ?string $requestedScope = null, ?string $redirectUri = null)
44
    {
45
        $this->code = $code;
46 2
        $this->scope = $scope;
47 2
        $this->clientIdentifier = $clientIdentifier;
48 2
        $this->resourceOwnerIdentifier = $resourceOwnerIdentifier;
49 2
        $this->expiresAt = $expiresAt;
50 2
        $this->requestedScope = $requestedScope;
51 2
        $this->redirectUri = $redirectUri;
52 2
    }
53 2
54
    /**
55
     * @return string
56
     */
57
    public function getCode(): string
58 2
    {
59
        return $this->code;
60 2
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function getScope(): string
66 2
    {
67
        return $this->scope;
68 2
    }
69
70
    /**
71
     * @return string
72
     */
73
    public function getClientIdentifier(): string
74 1
    {
75
        return $this->clientIdentifier;
76 1
    }
77
78
    /**
79
     * @return string
80
     */
81
    public function getResourceOwnerIdentifier(): string
82 1
    {
83
        return $this->resourceOwnerIdentifier;
84 1
    }
85
86
    public function isExpired(): bool
87
    {
88
        return time() > $this->expiresAt;
89
    }
90 1
91
    /**
92 1
     * @return null|string
93
     */
94
    public function getRequestedScope(): ?string
95
    {
96
        return $this->requestedScope;
97
    }
98 1
99
    /**
100 1
     * @return null|string
101
     */
102
    public function getRedirectUri(): ?string
103
    {
104
        return $this->redirectUri;
105
    }
106
}