/** * @expectedException \DomainException */ public function testMalformedJsonThrowsException() { JWT::jsonDecode('this is not valid JSON string'); }
<?php require_once './vendor/autoload.php'; use JWT\Authentication\JWT; $key = "example_key"; $token = array("iss" => "http://example.org", "aud" => "http://example.com", "iat" => 1356999524, "nbf" => 1357000000); $jwt = JWT::encode($token, $key); $decoded = JWT::decode($jwt, $key); print_r($decoded);