public function decode($data, $verify = true)
{
$sections = explode('.', $data);
if (count($sections) < 3) {
throw new Exception\DecodeException('Invalid number of sections (<3)');
}
list($header, $claims, $signature) = $sections;
$header = json_decode($this->base64Decode($header));
$claims = json_decode($this->base64Decode($claims));
$signature = $this->base64Decode($signature);
$key = $this->getHeader()->getKey();
if ($verify === true) {
if ($this->verify($key, $header, $claims, $signature) === false) {
throw new Exception\BadSignatureException('Signature did not verify');
}
}
return $claims;
}