readDataOnly; return true; } /** * Set read data only. * * @param bool $value * * @return self */ public function setReadDataOnly($value = true) { $this->readDataOnly = $value; return $this; } public function hasImageLoading(): bool { return $this->imageLoading; } public function setImageLoading(bool $value): self { $this->imageLoading = $value; return $this; } /** * Open file for reading. * * @param string $filename * * @return resource */ protected function openFile($filename) { // Check if file exists if (!file_exists($filename) || !is_readable($filename)) { throw new Exception("Could not open $filename for reading! File does not exist."); } // Open file $this->fileHandle = fopen($filename, 'rb'); if ($this->fileHandle === false) { throw new Exception("Could not open file $filename for reading."); } } /** * Can the current ReaderInterface read the file? * * @param string $filename * * @return bool */ public function canRead($filename) { // Check if file exists try { $this->openFile($filename); } catch (Exception $e) { return false; } if (is_resource($this->fileHandle)) { fclose($this->fileHandle); } return true; } }