| Total Complexity | 5 | 
| Total Lines | 45 | 
| Duplicated Lines | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php | ||
| 20 | final class FixtureFixtureFileUploader implements FixtureFileUploaderInterface | ||
| 21 | { | ||
| 22 | /** | ||
| 23 | * @var FilesystemInterface | ||
| 24 | */ | ||
| 25 | private FilesystemInterface $filesystem; | ||
| 26 | |||
| 27 | /** | ||
| 28 | * @param FilesystemInterface $filesystem | ||
| 29 | */ | ||
| 30 | public function __construct(FilesystemInterface $filesystem) | ||
| 31 |     { | ||
| 32 | $this->filesystem = $filesystem; | ||
| 33 | } | ||
| 34 | |||
| 35 | /** | ||
| 36 | * @param File $file | ||
| 37 | * @param string $target | ||
| 38 | */ | ||
| 39 | public function upload(File $file, string $target): void | ||
| 40 |     { | ||
| 41 | Assert::isInstanceOf($file, File::class); | ||
| 42 | |||
| 43 |         if ($this->filesystem->has($target)) { | ||
| 44 | $this->remove($target); | ||
| 45 | } | ||
| 46 | |||
| 47 | $this->filesystem->write( | ||
| 48 | $target, | ||
| 49 | (string) file_get_contents($file->getPathname()) | ||
| 50 | ); | ||
| 51 | } | ||
| 52 | |||
| 53 | /** | ||
| 54 | * @param string $path | ||
| 55 | * | ||
| 56 | * @return bool | ||
| 57 | */ | ||
| 58 | public function remove(string $path): bool | ||
| 65 | } | ||
| 66 | } | ||
| 67 |