/** * Define as mensagens de erro retornadas pelos métodos * @param array $erroList Um array contendo as mensagens de erro usadas na classe * @return Youtube */ public function setErroList(array $erroList) { parent::setErroList($erroList); if (isset($erroList["YOUTUBE_INVALIDO"])) { $this->erroList["YOUTUBE_INVALIDO"] = $erroList["YOUTUBE_INVALIDO"]; } return $this; }
/** * Método que valida o dado contido na URL * @param string $valor A url a ser testada * @return boolean Retorna TRUE caso a URL seja válida ou FALSE em caso contrário */ public static function validarTipo($valor) { $url = new Url(); $url->setValue($valor); return TRUE; }
/** * Define o nomo do arquivo ou a url do anexo * @param string $arquivoNome O novo arquivo ou url * @return Anexos * @throws LivroException */ public function setArquivoNome($arquivoNome) { if ($this->tipo == self::TIPO_VIDEO || $this->tipo == self::TIPO_AUDIO && $this->subtipo == self::SUBTIPO_AUDIO_LINK) { if (!filter_var($arquivoNome, FILTER_VALIDATE_URL)) { throw new LivroException("A url informada é inválida " . "para este tipo"); } } elseif ($this->tipo == self::TIPO_RA) { if (!is_numeric($arquivoNome)) { throw new LivroException("Você deve informar uma página válida " . "indicando qual página possue o padrão de realidade aumentada"); } } elseif ($this->tipo == self::TIPO_URL) { if (!Url::validarTipo($arquivoNome)) { throw new LivroException("A URL informada não é válida"); } } else { if (!Strings::validar($arquivoNome)) { throw new LivroException("O nome do arquivo é inválido"); } } $this->nome = $arquivoNome; return $this; }