thephpleague /
oauth2-server
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * @author Andrew Millington <[email protected]> |
||
| 5 | * @copyright Copyright (c) Alex Bilbie |
||
| 6 | * @license http://mit-license.org/ |
||
| 7 | * |
||
| 8 | * @link https://github.com/thephpleague/oauth2-server |
||
| 9 | */ |
||
| 10 | |||
| 11 | declare(strict_types=1); |
||
| 12 | |||
| 13 | namespace League\OAuth2\Server\Entities\Traits; |
||
| 14 | |||
| 15 | use DateTimeImmutable; |
||
| 16 | use League\OAuth2\Server\Entities\ClientEntityInterface; |
||
| 17 | use League\OAuth2\Server\Entities\ScopeEntityInterface; |
||
| 18 | |||
| 19 | trait DeviceCodeTrait |
||
| 20 | { |
||
| 21 | private bool $userApproved = false; |
||
| 22 | private bool $includeVerificationUriComplete = false; |
||
| 23 | private int $interval = 5; |
||
| 24 | private string $userCode; |
||
| 25 | private string $verificationUri; |
||
| 26 | private ?DateTimeImmutable $lastPolledAt = null; |
||
| 27 | |||
| 28 | 6 | public function getUserCode(): string |
|
| 29 | { |
||
| 30 | 6 | return $this->userCode; |
|
| 31 | } |
||
| 32 | |||
| 33 | 9 | public function setUserCode(string $userCode): void |
|
| 34 | { |
||
| 35 | 9 | $this->userCode = $userCode; |
|
| 36 | } |
||
| 37 | |||
| 38 | 6 | public function getVerificationUri(): string |
|
| 39 | { |
||
| 40 | 6 | return $this->verificationUri; |
|
| 41 | } |
||
| 42 | |||
| 43 | 6 | public function setVerificationUri(string $verificationUri): void |
|
| 44 | { |
||
| 45 | 6 | $this->verificationUri = $verificationUri; |
|
| 46 | } |
||
| 47 | |||
| 48 | 1 | public function getVerificationUriComplete(): string |
|
| 49 | { |
||
| 50 | 1 | return $this->verificationUri . '?user_code=' . $this->userCode; |
|
| 51 | } |
||
| 52 | |||
| 53 | abstract public function getClient(): ClientEntityInterface; |
||
| 54 | |||
| 55 | abstract public function getExpiryDateTime(): DateTimeImmutable; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @return ScopeEntityInterface[] |
||
| 59 | */ |
||
| 60 | abstract public function getScopes(): array; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @return non-empty-string |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 64 | */ |
||
| 65 | abstract public function getIdentifier(): string; |
||
| 66 | |||
| 67 | 2 | public function getLastPolledAt(): ?DateTimeImmutable |
|
| 68 | { |
||
| 69 | 2 | return $this->lastPolledAt; |
|
| 70 | } |
||
| 71 | |||
| 72 | 2 | public function setLastPolledAt(DateTimeImmutable $lastPolledAt): void |
|
| 73 | { |
||
| 74 | 2 | $this->lastPolledAt = $lastPolledAt; |
|
| 75 | } |
||
| 76 | |||
| 77 | 2 | public function getInterval(): int |
|
| 78 | { |
||
| 79 | 2 | return $this->interval; |
|
| 80 | } |
||
| 81 | |||
| 82 | 5 | public function setInterval(int $interval): void |
|
| 83 | { |
||
| 84 | 5 | $this->interval = $interval; |
|
| 85 | } |
||
| 86 | |||
| 87 | 2 | public function getUserApproved(): bool |
|
| 88 | { |
||
| 89 | 2 | return $this->userApproved; |
|
| 90 | } |
||
| 91 | |||
| 92 | 3 | public function setUserApproved(bool $userApproved): void |
|
| 93 | { |
||
| 94 | 3 | $this->userApproved = $userApproved; |
|
| 95 | } |
||
| 96 | |||
| 97 | public function getVerificationUriCompleteInAuthResponse(): bool |
||
| 98 | { |
||
| 99 | return $this->includeVerificationUriComplete; |
||
| 100 | } |
||
| 101 | |||
| 102 | public function setVerificationUriCompleteInAuthResponse(bool $includeVerificationUriComplete): void |
||
| 103 | { |
||
| 104 | $this->includeVerificationUriComplete = $includeVerificationUriComplete; |
||
| 105 | } |
||
| 106 | } |
||
| 107 |