/** * {@inheritDoc} */ public function decode($token) { // split token into header and data sections $token = $this->delegate->decode($token); $header = substr($token, 0, self::HEADER_LENGTH); $data = substr($token, self::HEADER_LENGTH); // unpack and verify expiration date $unpacked = unpack('Nexpires', $header); $expires = new \DateTime('@' . $unpacked['expires']); $now = new \DateTime(); if ($expires <= $now) { throw new TokenException('Token is expired', $token); } return $data; }
/** * {@inheritDoc} */ public function decode($token) { $token = $this->delegate->decode($token); // disregard header section return substr($token, self::HEADER_LENGTH); }