| Total Complexity | 6 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | class TokenBinding |
||
| 17 | { |
||
| 18 | public const TOKEN_BINDING_STATUS_PRESENT = 'present'; |
||
| 19 | public const TOKEN_BINDING_STATUS_SUPPORTED = 'supported'; |
||
| 20 | public const TOKEN_BINDING_STATUS_NOT_SUPPORTED = 'not-supported'; |
||
| 21 | /** |
||
| 22 | * @var string |
||
| 23 | */ |
||
| 24 | private $status; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var null|string |
||
| 28 | */ |
||
| 29 | private $id; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * TokenBinding constructor. |
||
| 33 | * |
||
| 34 | * @param string $status |
||
| 35 | * @param null|string $id |
||
| 36 | */ |
||
| 37 | public function __construct(string $status, ?string $id) |
||
| 38 | { |
||
| 39 | $this->status = $status; |
||
| 40 | $this->id = $id; |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @param array $json |
||
| 45 | * |
||
| 46 | * @return TokenBinding |
||
| 47 | */ |
||
| 48 | public static function createFormJson(array $json): self |
||
| 49 | { |
||
| 50 | if (!array_key_exists('status', $json)) { |
||
| 51 | throw new \InvalidArgumentException(); |
||
| 52 | } |
||
| 53 | |||
| 54 | return new self( |
||
| 55 | $json['status'], |
||
| 56 | array_key_exists('id', $json) ? $json['status'] : null |
||
| 57 | ); |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return string |
||
| 62 | */ |
||
| 63 | public function getStatus(): string |
||
| 64 | { |
||
| 65 | return $this->status; |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @return null|string |
||
| 70 | */ |
||
| 71 | public function getId(): ?string |
||
| 74 | } |
||
| 75 | } |
||
| 76 |