PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
← All changes | includes/sdk/s3/Aws/Token/Token.php +12 -3 1.2.13 → 1.4.2 View file →
@@ -2,9 +2,8 @@
2 2
3 3 namespace Dudlewebs\WPMCS\s3\Aws\Token;
4 4
5 5 use Dudlewebs\WPMCS\s3\Aws\Identity\BearerTokenIdentity;
6 -use Dudlewebs\WPMCS\s3\Aws\Token\TokenInterface;
7 6 /**
8 7 * Basic implementation of the AWS Token interface that allows callers to
9 8 * pass in an AWS token in the constructor.
10 9 */
@@ -11,8 +10,9 @@
11 10 class Token extends BearerTokenIdentity implements TokenInterface, \Serializable
12 11 {
13 12 protected $token;
14 13 protected $expires;
14 + protected ?TokenSource $source;
15 15 /**
16 16 * Constructs a new basic token object, with the specified AWS
17 17 * token
18 18 *
@@ -18,12 +18,13 @@
18 18 *
19 19 * @param string $token Security token to use
20 20 * @param int $expires UNIX timestamp for when the token expires
21 21 */
22 - public function __construct($token, $expires = null)
22 + public function __construct($token, $expires = null, ?TokenSource $source = null)
23 23 {
24 24 $this->token = $token;
25 25 $this->expires = $expires;
26 + $this->source = $source;
26 27 }
27 28 /**
28 29 * Sets the state of a token object
29 30 *
@@ -47,8 +48,15 @@
47 48 {
48 49 return $this->expires;
49 50 }
50 51 /**
52 + * @return string|null
53 + */
54 + public function getSource() : ?string
55 + {
56 + return $this->source?->value;
57 + }
58 + /**
51 59 * @return bool
52 60 */
53 61 public function isExpired()
54 62 {
@@ -58,9 +66,9 @@
58 66 * @return array
59 67 */
60 68 public function toArray()
61 69 {
62 - return ['token' => $this->token, 'expires' => $this->expires];
70 + return ['token' => $this->token, 'expires' => $this->expires, 'source' => $this->source?->value];
63 71 }
64 72 /**
65 73 * @return string
66 74 */
@@ -89,6 +97,7 @@
89 97 public function __unserialize($data)
90 98 {
91 99 $this->token = $data['token'];
92 100 $this->expires = $data['expires'];
101 + $this->source = isset($data['source']) ? TokenSource::from($data['source']) : null;
93 102 }
94 103 }