create() public method

Create a new claim
public create ( string $name, mixed $value ) : Lcobucci\JWT\Claim
$name string
$value mixed
return Lcobucci\JWT\Claim
Esempio n. 1
0
 /**
  * Configures a claim item
  *
  * @param string $name
  * @param mixed $value
  *
  * @return Builder
  *
  * @throws BadMethodCallException When data has been already signed
  */
 public function set($name, $value)
 {
     if ($this->signature) {
         throw new BadMethodCallException('You must unsign before make changes');
     }
     $this->claims[(string) $name] = $this->claimFactory->create($name, $value);
     return $this;
 }
Esempio n. 2
0
 /**
  * Parses the claim set from a string
  *
  * @param string $data
  *
  * @return array
  */
 protected function parseClaims($data)
 {
     $claims = (array) $this->decoder->jsonDecode($this->decoder->base64UrlDecode($data));
     foreach ($claims as $name => &$value) {
         $value = $this->claimFactory->create($name, $value);
     }
     return $claims;
 }
Esempio n. 3
0
 /**
  * Configures a claim item
  *
  * @param string $name
  * @param mixed $value
  *
  * @return Builder
  *
  * @throws BadMethodCallException When data has been already signed
  */
 public function with(string $name, $value) : Builder
 {
     if ($this->signature) {
         throw new BadMethodCallException('You must unsign before making changes');
     }
     $this->claims[$name] = $this->claimFactory->create($name, $value);
     return $this;
 }