Example #1
0
 /**
  * @param $file
  * @return $this
  */
 public function setFile($file, \Closure $callback = null)
 {
     if ($this->ftp) {
         $file = $this->getFileFromFtp($file);
         $this->file = $this->ftp->getFile();
     }
     libxml_clear_errors();
     libxml_use_internal_errors(true);
     if (!is_null($callback)) {
         $callback($file);
     }
     $this->xmlr->open($file);
     $errors = libxml_get_errors();
     if (!empty($errors)) {
         $last_error = libxml_get_last_error();
         throw new \RuntimeException(sprintf("%s %s", $last_error->message, $file));
     }
     libxml_clear_errors();
     return $this;
 }