From: Christian Weiske Date: Wed, 28 Mar 2012 04:39:25 +0000 (+0200) Subject: determine mime type by file extension, not by geshi type X-Git-Tag: v0.1.0~84 X-Git-Url: https://git.cweiske.de/phorkie.git/commitdiff_plain/3f18e7e8ce995bb209f8409cd8d00d8267dfa04f?ds=sidebyside determine mime type by file extension, not by geshi type --- diff --git a/src/Phorkie/File.php b/src/Phorkie/File.php index 84f7eb5..bf2eb60 100644 --- a/src/Phorkie/File.php +++ b/src/Phorkie/File.php @@ -58,6 +58,16 @@ class File return basename($this->path); } + /** + * Get file extension without dot + * + * @return string + */ + public function getExt() + { + return substr($this->path, strrpos($this->path, '.') + 1); + } + /** * Returns the type of the file, as used by Geshi * @@ -65,7 +75,7 @@ class File */ public function getType() { - $ext = substr($this->path, strrpos($this->path, '.') + 1); + $ext = $this->getExt(); if (isset(static::$arTypeMap[$ext])) { $ext = static::$arTypeMap[$ext]; } @@ -93,11 +103,11 @@ class File public function getMimeType() { - $type = $this->getType(); - if (!isset(static::$arMimeTypeMap[$type])) { + $ext = $this->getExt(); + if (!isset(static::$arMimeTypeMap[$ext])) { return null; } - return static::$arMimeTypeMap[$type]; + return static::$arMimeTypeMap[$ext]; } /**