paste deletion is possible now
[phorkie.git] / src / Phorkie / File.php
index 84f7eb5301b448f72a8ce322a04d1ce5926367a9..3c6ea4b42e687b532563e54633a4557a4360b9fe 100644 (file)
@@ -42,7 +42,7 @@ class File
         'html' => 'xml',
     );
 
-    public function __construct($path, Repository $repo)
+    public function __construct($path, Repository $repo = null)
     {
         $this->path = $path;
         $this->repo = $repo;
@@ -58,6 +58,26 @@ class File
         return basename($this->path);
     }
 
+    /**
+     * Return the full path to the file
+     *
+     * @return string
+     */
+    public function getPath()
+    {
+        return $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 +85,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 +113,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];
     }
 
     /**