create() public method

Create a new claim
public create ( string $name, mixed $value ) : Lcobucci\JWT\Claim
$name string
$value mixed
return Lcobucci\JWT\Claim
示例#1
0
文件: Builder.php 项目: jackysong/jwt
 /**
  * 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;
 }
示例#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;
 }
示例#3
0
文件: Builder.php 项目: lcobucci/jwt
 /**
  * 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;
 }