path; } /** * Set Path. * * @param string $pValue File path * @param bool $pVerifyFile Verify file * * @throws FileNotFoundException * * @return self */ public function setPath(string $pValue = '', bool $pVerifyFile = true): self { if ($pVerifyFile) { if (!\file_exists($pValue)) { throw new FileNotFoundException($pValue); } } $this->path = $pValue; if ($pVerifyFile) { if (0 == $this->width && 0 == $this->height) { list($this->width, $this->height) = \getimagesize($this->getPath()); } } return $this; } public function getContents(): string { return CommonFile::fileGetContents($this->getPath()); } public function getExtension(): string { return \pathinfo($this->getPath(), PATHINFO_EXTENSION); } /** * @throws FileNotFoundException */ public function getMimeType(): string { if (!CommonFile::fileExists($this->getPath())) { throw new FileNotFoundException($this->getPath()); } $image = \getimagesizefromstring(CommonFile::fileGetContents($this->getPath())); if (\is_array($image)) { return \image_type_to_mime_type($image[2]); } return \mime_content_type($this->getPath()); } public function getIndexedFilename(): string { $output = \str_replace('.' . $this->getExtension(), '', \pathinfo($this->getPath(), PATHINFO_FILENAME)); $output .= $this->getImageIndex(); $output .= '.' . $this->getExtension(); $output = \str_replace(' ', '_', $output); return $output; } }