/** * Initialize from a JSON string. * * @param string $json JSON * @throws \UnexpectedValueException If JSON is malformed * @return self */ public static function fromJSON($json) { $claims = array(); $fields = json_decode($json, true, 32, JSON_BIGINT_AS_STRING); if (!is_array($fields)) { throw new \UnexpectedValueException("Invalid JSON."); } foreach ($fields as $name => $value) { $claims[] = Claim::fromNameAndValue($name, $value); } return new self(...$claims); }
/** * Constructor * * @param Claim $claim */ public function __construct(Claim $claim) { parent::__construct($claim->name(), $claim->value()); }