major refactoring under the hood
[pharext/pharext] / src / pharext / Tempname.php
diff --git a/src/pharext/Tempname.php b/src/pharext/Tempname.php
new file mode 100644 (file)
index 0000000..b5e7520
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+
+namespace pharext;
+
+/**
+ * A temporary file/directory name
+ */
+class Tempname
+{
+       /**
+        * @var string
+        */
+       private $name;
+
+       /**
+        * @param string $prefix uniqid() prefix
+        * @param string $suffix e.g. file extension
+        */
+       public function __construct($prefix, $suffix = null) {
+               $this->name = sys_get_temp_dir() . "/" . uniqid($prefix) . $suffix;
+       }
+
+       /**
+        * @return string
+        */
+       public function __toString() {
+               return (string) $this->name;
+       }
+}