/** * @param string $filepath_ * @param \Components\Io_Mimetype $mimeType_ * * @throws \Components\Runtime_Exception * * @return \Components\Mail_Part_Image */ public static function forFilePath($filepath_, Io_Mimetype $mimeType_ = null) { if (false === @is_file($filepath_)) { throw new Io_Exception('mail/part/file', sprintf('Unable to resolve file for given path [filepath: %1$s].', $filepath_)); } if (null === $mimeType_) { $mimeType_ = Io_Mimetype::forFilePath($filepath_); } if (null === $mimeType_) { throw new Io_Exception('mail/part/file', sprintf('Unable to resolve mimetype for given path [filepath: %1$s].', $filepath_)); } return new static(@basename($filepath_), @file_get_contents($filepath_), $mimeType_); }
/** * @param string $filename_ * * @return \Components\Io_Mimetype */ public static function mimeType($filename_) { return Io_Mimetype::forFilePath($filename_); }
/** * @return boolean */ public function isImage() { if (@is_file($this->m_path)) { return Io_Mimetype::forFilePath($this->m_path)->isImage(); } return Io_Mimetype::forFileName($this->m_path); }
/** * @return \Components\Io_Mimetype */ public function getMimetype() { if (null === $this->m_mimeType) { if ($this->exists()) { return $this->m_mimeType = Io_Mimetype::forFilePath($this->m_pathAsString); } return $this->m_mimeType = Io_Mimetype::forFileExtension($this->getExtension()); } return $this->m_mimeType; }