Since: 2.0.0
Author: Luís Otávio Cobucci Oblonczyk (lcobucci@gmail.com)
コード例 #1
0
ファイル: ParserTest.php プロジェクト: KennedyTedesco/jwt
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->decoder = $this->getMock(Decoder::class);
     $this->claimFactory = $this->getMock(ClaimFactory::class, [], [], '', false);
     $this->defaultClaim = $this->getMock(Claim::class);
     $this->claimFactory->expects($this->any())->method('create')->willReturn($this->defaultClaim);
 }
コード例 #2
0
ファイル: ParserTest.php プロジェクト: lcobucci/jwt
 /**
  * @before
  */
 public function createDependencies()
 {
     $this->decoder = $this->createMock(Decoder::class);
     $this->claimFactory = $this->createMock(ClaimFactory::class);
     $this->defaultClaim = $this->createMock(Claim::class);
     $this->claimFactory->method('create')->willReturn($this->defaultClaim);
 }
コード例 #3
0
ファイル: BuilderTest.php プロジェクト: lcobucci/jwt
 /**
  * @before
  */
 public function initializeDependencies()
 {
     $this->encoder = $this->createMock(Encoder::class);
     $this->claimFactory = $this->createMock(ClaimFactory::class);
     $this->defaultClaim = $this->createMock(Claim::class);
     $this->claimFactory->expects($this->any())->method('create')->willReturn($this->defaultClaim);
 }
コード例 #4
0
ファイル: Parser.php プロジェクト: AlefeVariani/jwt
 /**
  * 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;
 }
コード例 #5
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;
 }
コード例 #6
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;
 }