Since: 2.0.0
Author: Luís Otávio Cobucci Oblonczyk (lcobucci@gmail.com)
Exemple #1
0
 /**
  * {@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);
 }
Exemple #2
0
 /**
  * @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);
 }
Exemple #3
0
 /**
  * @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);
 }
Exemple #4
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;
 }
Exemple #5
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;
 }
Exemple #6
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;
 }