Total Complexity | 6 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
19 | class TokenBinding |
||
20 | { |
||
21 | public const TOKEN_BINDING_STATUS_PRESENT = 'present'; |
||
22 | public const TOKEN_BINDING_STATUS_SUPPORTED = 'supported'; |
||
23 | public const TOKEN_BINDING_STATUS_NOT_SUPPORTED = 'not-supported'; |
||
24 | |||
25 | private $status; |
||
26 | |||
27 | private $id; |
||
28 | |||
29 | public function __construct(string $status, ?string $id) |
||
30 | { |
||
31 | Assertion::false(self::TOKEN_BINDING_STATUS_PRESENT === $status && !$id, 'The member "id" is required when status is "present"'); |
||
32 | $this->status = $status; |
||
33 | $this->id = $id; |
||
34 | } |
||
35 | |||
36 | public static function createFormArray(array $json): self |
||
37 | { |
||
38 | Assertion::keyExists($json, 'status', 'The member "status" is required'); |
||
39 | $status = $json['status']; |
||
40 | $id = array_key_exists('id', $json) ? Base64Url::decode($json['id']) : null; |
||
41 | |||
42 | return new self($status, $id); |
||
43 | } |
||
44 | |||
45 | public function getStatus(): string |
||
46 | { |
||
47 | return $this->status; |
||
48 | } |
||
49 | |||
50 | public function getId(): ?string |
||
53 | } |
||
54 | } |
||
55 |