/** * @param string $tokenString */ public function setTokenFromString($tokenString) { $this->tokenString = $tokenString; $segments = explode('.', $tokenString); if (count($segments) !== 3) { throw new \InvalidArgumentException("Not a JWT token string"); } list($headerBase64, $claimsBase64, $signatureBase64) = $segments; $this->payload = "{$headerBase64}.{$claimsBase64}"; $decoder = new Decoder(); $this->header = $decoder->decode($headerBase64); $this->claims = $decoder->decode($claimsBase64); $this->signature = $decoder->base64Decode($signatureBase64); }
/** * @param string $data * @param array $source * * @test * @dataProvider testSetProvider */ public function willDecodeTestCasesFromJwtDotIo($source, $data) { $decoder = new Decoder(); $this->assertSame($source, $decoder->decode($data)); }