| Total Complexity | 9 |
| Total Lines | 92 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 2 |
| 1 | <?php |
||
| 16 | final class Token implements TokenInterface, \JsonSerializable |
||
| 17 | { |
||
| 18 | /** @var string */ |
||
| 19 | private $id; |
||
| 20 | |||
| 21 | /** @var \DateTimeInterface|null */ |
||
| 22 | private $expiresAt; |
||
| 23 | |||
| 24 | /** @var array */ |
||
| 25 | private $payload; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @param string $id |
||
| 29 | * @param array $payload |
||
| 30 | * @param \DateTimeInterface|null $expiresAt |
||
| 31 | */ |
||
| 32 | public function __construct(string $id, array $payload, \DateTimeInterface $expiresAt = null) |
||
| 33 | { |
||
| 34 | $this->id = $id; |
||
| 35 | $this->expiresAt = $expiresAt; |
||
| 36 | $this->payload = $payload; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @return string |
||
| 41 | */ |
||
| 42 | public function __toString(): string |
||
| 43 | { |
||
| 44 | return $this->id; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @inheritDoc |
||
| 49 | */ |
||
| 50 | public function getID(): string |
||
| 51 | { |
||
| 52 | return $this->id; |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @inheritDoc |
||
| 57 | */ |
||
| 58 | public function getExpiresAt(): ?\DateTimeInterface |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @inheritDoc |
||
| 65 | */ |
||
| 66 | public function getPayload(): array |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @return string |
||
| 73 | */ |
||
| 74 | public function jsonSerialize(): string |
||
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * Pack token data into array form. |
||
| 81 | * |
||
| 82 | * @return array |
||
| 83 | */ |
||
| 84 | public function pack(): array |
||
| 90 | ]; |
||
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Unpack token from serialized data. |
||
| 95 | * |
||
| 96 | * @param array $data |
||
| 97 | * @return Token |
||
| 98 | * @throws \Exception |
||
| 99 | */ |
||
| 100 | public static function unpack(array $data): Token |
||
| 110 |