/** * Redirect to the proper method * checking the type of token. * * @param \ComicAPI\Tokens\TokenInterface $token Instance of Token. * * @return bool */ protected function valid(TokenInterface $token) { if ($token->getType() === ComicAPI::MARVEL) { return $this->validMarvel($token); } if ($token->getType() === ComicAPI::COMICVINE) { return $this->validComicVine($token); } return false; }
/** * Instance of TokenInterface has 'isValid()' * method to checking validation. Instead of * returning false, throws an exception. * * @param \ComicAPI\Tokens\TokenInterface $token Instance of Token. * * @throws \ComicAPI\Exceptions\ComicApiException */ protected function isValidSingle(TokenInterface $token) { if ($token->isValid() === false) { throw new ComicApiException(sprintf("The token %s is invalid.", $token->getType())); } }