/** * @return \Components\Io_Mimetype */ public function getMimetype() { if (null === $this->m_mimeType) { if (!($this->m_mimeType = Io_Mimetype::forFileName($this->m_uri->getPath()))) { $this->m_mimeType = Io_Mimetype::TEXT_HTML(Io_Charset::UTF_8()); } } return $this->m_mimeType; }
/** * @param string $filename_ * @param string $content_ * @param \Components\Io_Mimetype $mimeType_ * * @throws \Components\Runtime_Exception * * @return \Components\Mail_Part_Image */ public static function forFileContents($filename_, $content_, Io_Mimetype $mimeType_ = null) { if (null === $mimeType_) { $mimeType_ = Io_Mimetype::forFileName($filename_); } if (null === $mimeType_) { throw new Io_Exception('mail/part/file', sprintf('Unable to resolve mimetype for given filename [filename: %1$s].', $filename_)); } return new static($filename_, $content_, $mimeType_); }
/** * @param \Components\Io_Mimetype $mimeType_ * @param string $path_ * @param integer $accessModeMask_ * * @return \Components\Io_File */ public static function forMimetype($path_, $accessModeMask_ = self::READ, Io_Mimetype $mimeType_ = null) { if (null === $mimeType_) { $mimeType_ = Io_Mimetype::forFileName($path_); } if (null === $mimeType_) { return new static($path_, $accessModeMask_); } if (isset(self::$m_implForMimetype[$mimeType_->name()])) { $type = self::$m_implForMimetype[$mimeType_->name()]; $instance = new $type($path_, $accessModeMask_); $instance->m_mimeType = $mimeType_; return $instance; } return new static($path_, $accessModeMask_); }
/** * @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); }