/** * {@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); }
/** * @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); }
/** * @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); }
/** * 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; }
/** * 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; }
/** * 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; }