Completed
Push — master ( d61ccd...74eea6 )
by Alexandre
03:47
created

Config::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Alexandre
5
 * Date: 06/03/2018
6
 * Time: 22:28
7
 */
8
9
namespace OAuth2;
10
11
12
13
use OAuth2\ScopePolicy\Policies\ScopePolicyInterface;
14
15
class Config
16
{
17
    /**
18
     * @var ScopePolicyInterface
19
     */
20
    protected $scopePolicy;
21
22
    /**
23
     * @var bool
24
     */
25
    protected $issueNewRefreshToken = true;
26
27
    /**
28
     * @var bool
29
     */
30
    protected $revokeOldRefreshToken = true;
31
32
    /**
33
     * @var bool
34
     */
35
    protected $revokeTokensWhenAuthorizationCodeIsReused = true;
36
37
    public function __construct(ScopePolicyInterface $scopePolicy)
38
    {
39
        $this->scopePolicy = $scopePolicy;
40
    }
41
42
    /**
43
     * @return ScopePolicyInterface
44
     */
45
    public function getScopePolicy(): ScopePolicyInterface
46
    {
47
        return $this->scopePolicy;
48
    }
49
50
    /**
51
     * @param ScopePolicyInterface $scopePolicy
52
     */
53
    public function setScopePolicy(ScopePolicyInterface $scopePolicy): void
54
    {
55
        $this->scopePolicy = $scopePolicy;
56
    }
57
58
    /**
59
     * @return bool
60
     */
61
    public function mayIssueNewRefreshToken(): bool
62
    {
63
        return $this->issueNewRefreshToken;
64
    }
65
66
    /**
67
     * @param bool $issueNewRefreshToken
68
     */
69
    public function setIssueNewRefreshToken(bool $issueNewRefreshToken): void
70
    {
71
        if($issueNewRefreshToken) {
72
            $this->setRevokeOldRefreshToken(true);
73
        }
74
        $this->issueNewRefreshToken = $issueNewRefreshToken;
75
    }
76
77
    /**
78
     * @return bool
79
     */
80
    public function mayRevokeOldRefreshToken(): bool
81
    {
82
        return $this->revokeOldRefreshToken;
83
    }
84
85
    /**
86
     * @param bool $revokeOldRefreshToken
87
     */
88
    public function setRevokeOldRefreshToken(bool $revokeOldRefreshToken): void
89
    {
90
        $this->revokeOldRefreshToken = $revokeOldRefreshToken;
91
    }
92
93
    /**
94
     * @return bool
95
     */
96
    public function shouldRevokeTokensWhenAuthorizationCodeIsReused(): bool
97
    {
98
        return $this->revokeTokensWhenAuthorizationCodeIsReused;
99
    }
100
101
    /**
102
     * @param bool $revokeTokensWhenAuthorizationCodeIsReused
103
     */
104
    public function setRevokeTokensWhenAuthorizationCodeIsReused(bool $revokeTokensWhenAuthorizationCodeIsReused): void
105
    {
106
        $this->revokeTokensWhenAuthorizationCodeIsReused = $revokeTokensWhenAuthorizationCodeIsReused;
107
    }
108
}