Skip to content

Commit 3ca4ef6

Browse files
committed
Add class to configuration token expiration times.
1 parent 96b401a commit 3ca4ef6

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

src/Config/Expiration.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Pdsinterop\Solid\Auth\Config;
4+
5+
use DateInterval;
6+
7+
class Expiration
8+
{
9+
////////////////////////////// CLASS PROPERTIES \\\\\\\\\\\\\\\\\\\\\\\\\\\\
10+
11+
/** @var string */
12+
private $accessToken;
13+
/** @var string */
14+
private $authCode;
15+
/** @var string */
16+
private $refreshToken;
17+
18+
//////////////////////////// GETTERS AND SETTERS \\\\\\\\\\\\\\\\\\\\\\\\\\\
19+
20+
public function forAccessToken() : DateInterval
21+
{
22+
return new DateInterval($this->accessToken);
23+
}
24+
25+
public function forAuthCode() : DateInterval
26+
{
27+
return new DateInterval($this->authCode);
28+
}
29+
30+
public function forRefreshToken() : DateInterval
31+
{
32+
return new DateInterval($this->refreshToken);
33+
}
34+
35+
//////////////////////////////// PUBLIC API \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
36+
37+
public function __construct(string $accessTokenExpires, string $authCodeExpires, string $refreshTokenExpires)
38+
{
39+
$this->accessToken = $accessTokenExpires;
40+
$this->authCode = $authCodeExpires;
41+
$this->refreshToken = $refreshTokenExpires;
42+
}
43+
}

0 commit comments

Comments
 (0)