major refactoring under the hood
[pharext/pharext] / src / pharext / Tempdir.php
1 <?php
2
3 namespace pharext;
4
5 /**
6 * Create a temporary directory
7 */
8 class Tempdir extends \SplFileInfo
9 {
10 /**
11 * @param string $prefix prefix to uniqid()
12 * @throws \pharext\Exception
13 */
14 public function __construct($prefix) {
15 $temp = new Tempname($prefix);
16 if (!is_dir($temp) && !mkdir($temp, 0700, true)) {
17 throw new Exception("Could not create tempdir: ".error_get_last()["message"]);
18 }
19 parent::__construct($temp);
20 }
21 }