@@ 36-47 (lines=12) @@ | ||
33 | * @param string $baseDir |
|
34 | * @param bool $includeRandomPart |
|
35 | */ |
|
36 | public function __construct($filename = 'tmp', $extension = '', $baseDir = '', $includeRandomPart = true) |
|
37 | { |
|
38 | if (empty($baseDir)) { |
|
39 | $baseDir = sys_get_temp_dir(); |
|
40 | } |
|
41 | if ($includeRandomPart) { |
|
42 | $random = static::randomString(); |
|
43 | $filename = "{$filename}_{$random}"; |
|
44 | } |
|
45 | $filename .= $extension; |
|
46 | parent::__construct("{$baseDir}/{$filename}"); |
|
47 | } |
|
48 | ||
49 | /** |
|
50 | * Generate a suitably random string to use as the suffix for our |
@@ 57-67 (lines=11) @@ | ||
54 | * @param string $base |
|
55 | * @param bool $includeRandomPart |
|
56 | */ |
|
57 | public function __construct($prefix = 'tmp', $base = '', $includeRandomPart = true) |
|
58 | { |
|
59 | if (empty($base)) { |
|
60 | $base = sys_get_temp_dir(); |
|
61 | } |
|
62 | $path = "{$base}/{$prefix}"; |
|
63 | if ($includeRandomPart) { |
|
64 | $path = static::randomLocation($path); |
|
65 | } |
|
66 | parent::__construct(["$path"]); |
|
67 | } |
|
68 | ||
69 | /** |
|
70 | * Add a random part to a path, ensuring that the directory does |