Exemplo n.º 1
0
Arquivo: Claims.php Projeto: sop/jwx
 /**
  * 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);
 }
Exemplo n.º 2
0
 /**
  * Constructor
  *
  * @param Claim $claim
  */
 public function __construct(Claim $claim)
 {
     parent::__construct($claim->name(), $claim->value());
 }