Conditions | 2 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
27 | public function download(string $url): File |
||
28 | { |
||
29 | $path = rtrim(sys_get_temp_dir(), \DIRECTORY_SEPARATOR) . \DIRECTORY_SEPARATOR . md5(random_bytes(10)); |
||
30 | $pathInfo = pathinfo($url); |
||
31 | $extension = $pathInfo['extension'] ?? null; |
||
32 | if (null !== $extension) { |
||
33 | $path .= '.' . $extension; |
||
34 | } |
||
35 | $contents = file_get_contents($url); |
||
36 | Assert::string($contents, sprintf('Content of file in path %s is null', $path)); |
||
37 | $this->filesystem->dumpFile($path, $contents); |
||
38 | |||
39 | return new File($path); |
||
40 | } |
||
42 |