public function fromString($token)
    {
        $segments = explode('.', $token);

        if (count($segments) == 3)
        {
            list($header, $payload, $signature) = $segments;

            $this->_header    = $this->_fromJson($this->_fromBase64url($header));
            $this->_claims    = $this->_fromJson($this->_fromBase64url($payload));
            $this->_signature = $this->_fromBase64url($signature);

            if(isset($this->_header['alg'])) {
                $this->setAlgorithm($this->_header['alg']);
            } else {
                $this->setAlgorithm('none');
            }
        }
        else throw new InvalidArgumentException(sprintf('The token "%s" is an invalid JWT', $token));

        return $this;
    }