1 | <?php |
||
19 | trait FileHelper |
||
20 | { |
||
21 | /** |
||
22 | * @return BuilderInterface |
||
23 | */ |
||
24 | abstract public function getBuilder(); |
||
25 | |||
26 | /** |
||
27 | * @param string|null $basePath |
||
28 | * |
||
29 | * @return LocalFile |
||
30 | */ |
||
31 | 1 | public function getTemporaryFile($basePath = null) |
|
32 | { |
||
33 | 1 | $path = $basePath ?: '/tmp/file/'; |
|
34 | 1 | $file = $this->getBuilder()->build( |
|
35 | 1 | LocalFile::class, |
|
36 | sprintf( |
||
37 | 1 | '%s%s.tmp', |
|
38 | 1 | $this->addTrailingSlash($path), |
|
39 | 1 | uniqid('file') |
|
40 | ) |
||
41 | ); |
||
42 | |||
43 | 1 | return $file; |
|
44 | } |
||
45 | |||
46 | /** |
||
47 | * @param string $path |
||
48 | * |
||
49 | * @return string |
||
50 | */ |
||
51 | 1 | public function addTrailingSlash($path) |
|
55 | } |
||
56 |