/** * Check rules for ComicVine API key. * * @param \ComicAPI\Tokens\TokenInterface $value Instance of Token. * * @return bool */ protected function validComicVine(TokenInterface $value) { $valid = new Rules\AllOf(new Rules\Length(40), new Rules\StringType()); if ($valid->validate($value->getToken()) === false) { return false; } return true; }
/** * 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())); } }