1 | <?php |
||
7 | class Token implements \JsonSerializable |
||
8 | { |
||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | protected $id; |
||
13 | |||
14 | /** |
||
15 | * @var \DateTime |
||
16 | */ |
||
17 | protected $expires; |
||
18 | |||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $catalogs; |
||
23 | |||
24 | /** |
||
25 | * @param string $id |
||
26 | * @param \DateTime $expires |
||
27 | */ |
||
28 | 30 | public function __construct($id, \DateTime $expires) |
|
34 | |||
35 | /** |
||
36 | * @return string |
||
37 | */ |
||
38 | 12 | public function getId() |
|
42 | |||
43 | /** |
||
44 | * Adds a service catalog, using the array output of a token-call. |
||
45 | * |
||
46 | * @param string $type The service type |
||
47 | * @param string $name The service name |
||
48 | * @param array $endpoints Array of endpoints |
||
49 | */ |
||
50 | 22 | public function addServiceCatalog($type, $name, array $endpoints) |
|
73 | |||
74 | /** |
||
75 | * @param string $type |
||
76 | * @param string $name |
||
77 | * |
||
78 | * @throws TokenException |
||
79 | * |
||
80 | * @return array |
||
81 | */ |
||
82 | 14 | public function getServiceCatalog($type, $name = null) |
|
100 | |||
101 | /** |
||
102 | * @return \DateTime |
||
103 | */ |
||
104 | 13 | public function getExpirationDate() |
|
108 | |||
109 | /** |
||
110 | * @return bool |
||
111 | */ |
||
112 | 7 | public function isExpired() |
|
116 | |||
117 | /** |
||
118 | * Factory method to use with Keystone token responses, or a json_encoded Token instance. |
||
119 | * |
||
120 | * @param array $content |
||
121 | * |
||
122 | * @throws TokenException |
||
123 | * |
||
124 | * @return static |
||
125 | */ |
||
126 | 21 | public static function create(array $content) |
|
158 | |||
159 | /** |
||
160 | * @inheritdoc |
||
161 | */ |
||
162 | 8 | public function jsonSerialize() |
|
186 | |||
187 | /** |
||
188 | * @param array $array |
||
189 | * @param string $key |
||
190 | * |
||
191 | * @return mixed |
||
192 | */ |
||
193 | 21 | protected static function arrayGet(array $array, $key) |
|
206 | } |
||
207 |