1 | <?php |
||
21 | final class FileTemp extends AbstractFilePath implements FilePathInterface |
||
22 | { |
||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | private $name; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | private $root; |
||
32 | |||
33 | /** |
||
34 | * @param string|null $name |
||
35 | * @param string|null $root |
||
36 | */ |
||
37 | public function __construct(string $name = null, string $root = null) |
||
44 | |||
45 | /** |
||
46 | * Automatically release the temporary file. |
||
47 | */ |
||
48 | public function __destruct() |
||
52 | |||
53 | /** |
||
54 | * @param string|null $name |
||
55 | * @param string|null $root |
||
56 | * @param string|null $contents |
||
57 | * |
||
58 | * @return self |
||
59 | */ |
||
60 | public static function create(string $name = null, string $root = null, string $contents = null): self |
||
70 | |||
71 | /** |
||
72 | * @return string |
||
73 | */ |
||
74 | public function getName(): string |
||
78 | |||
79 | /** |
||
80 | * @param string|null $name |
||
81 | * |
||
82 | * @return self |
||
83 | */ |
||
84 | public function setName(string $name = null): self |
||
91 | |||
92 | /** |
||
93 | * @return string |
||
94 | */ |
||
95 | public function getRoot(): string |
||
99 | |||
100 | /** |
||
101 | * @param string|null $path |
||
102 | * |
||
103 | * @return FileTemp |
||
104 | */ |
||
105 | public function setRoot(string $path = null): self |
||
112 | |||
113 | /** |
||
114 | * @return bool |
||
115 | */ |
||
116 | public function isAcquired(): bool |
||
120 | |||
121 | /** |
||
122 | * @return self |
||
123 | */ |
||
124 | public function acquire(): self |
||
140 | |||
141 | /** |
||
142 | * @param bool $remove |
||
143 | * |
||
144 | * @return self |
||
145 | */ |
||
146 | public function release(bool $remove = true): self |
||
160 | |||
161 | /** |
||
162 | * @param string $contents |
||
163 | * @param bool $append |
||
164 | */ |
||
165 | protected function doSetContents(string $contents, bool $append): void |
||
173 | |||
174 | /** |
||
175 | * @param string $message |
||
176 | */ |
||
177 | private function requireReleasedState(string $message): void |
||
183 | } |
||
184 |