| Total Complexity | 9 | 
| Total Lines | 70 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 18 | class ClientData | ||
| 19 | { | ||
| 20 | /** | ||
| 21 | * @var string | ||
| 22 | */ | ||
| 23 | private $rawData; | ||
| 24 | |||
| 25 | /** | ||
| 26 | * @var string | ||
| 27 | */ | ||
| 28 | private $typ; | ||
| 29 | |||
| 30 | /** | ||
| 31 | * @var string | ||
| 32 | */ | ||
| 33 | private $challenge; | ||
| 34 | |||
| 35 | /** | ||
| 36 | * @var string | ||
| 37 | */ | ||
| 38 | private $origin; | ||
| 39 | |||
| 40 | /** | ||
| 41 | * @var string | ||
| 42 | */ | ||
| 43 | private $cid_pubkey; | ||
| 44 | |||
| 45 | public function __construct(string $clientData) | ||
| 46 |     { | ||
| 47 | $this->rawData = Base64Url::decode($clientData); | ||
| 48 | $clientData = json_decode($this->rawData, true); | ||
| 49 |         if (!\is_array($clientData)) { | ||
| 50 |             throw new \InvalidArgumentException('Invalid client data.'); | ||
| 51 | } | ||
| 52 | |||
| 53 | $diff = array_diff_key(get_class_vars(self::class), $clientData); | ||
| 54 | unset($diff['rawData'], $diff['cid_pubkey']); | ||
| 55 | |||
| 56 |         if (!empty($diff)) { | ||
| 57 |             throw new \InvalidArgumentException('Invalid client data.'); | ||
| 58 | } | ||
| 59 | |||
| 60 |         foreach ($clientData as $k => $v) { | ||
| 61 | $this->$k = $v; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | public function getRawData(): string | ||
| 66 |     { | ||
| 67 | return $this->rawData; | ||
| 68 | } | ||
| 69 | |||
| 70 | public function getType(): string | ||
| 71 |     { | ||
| 72 | return $this->typ; | ||
| 73 | } | ||
| 74 | |||
| 75 | public function getChallenge(): string | ||
| 78 | } | ||
| 79 | |||
| 80 | public function getOrigin(): string | ||
| 83 | } | ||
| 84 | |||
| 85 | public function getChannelIdPublicKey(): string | ||
| 88 | } | ||
| 89 | } | ||
| 90 |