refactor(StorageService): change remove methods to return bool

This commit is contained in:
Jérémy Munsch 2026-11-03 15:53:07 +01:00
parent b56f43b5c8
commit 08fda2cdfd
Signed by: forge-joniko
GPG key ID: D7EFE2F5CB6CC0E4
3 changed files with 10 additions and 8 deletions

View file

@ -31,7 +31,7 @@ interface StorageService
public function getFile(StorageFilePath $filePath): ?FileStream;
public function remove(StorageFilePath $filePath): void;
public function remove(StorageFilePath $filePath): bool;
public function removeFromDisk(StorageFilePath $filePath, DiskName $disk): void;
public function removeFromDisk(StorageFilePath $filePath, DiskName $disk): bool;
}

View file

@ -16,8 +16,8 @@ use Uwil\Storage\Contracts\StorageService as StorageServiceContract;
* @method static bool fileExists(\Uwil\Storage\Lib\ValueObjects\StorageFilePath $filePath)
* @method static bool fileExistsOnDisk(\Uwil\Storage\Lib\ValueObjects\StorageFilePath $filePath, \Uwil\Storage\Lib\ValueObjects\DiskName $disk)
* @method static \Uwil\Storage\Lib\ValueObjects\FileStream|null getFile(\Uwil\Storage\Lib\ValueObjects\StorageFilePath $filePath)
* @method static void remove(\Uwil\Storage\Lib\ValueObjects\StorageFilePath $filePath)
* @method static void removeFromDisk(\Uwil\Storage\Lib\ValueObjects\StorageFilePath $filePath, \Uwil\Storage\Lib\ValueObjects\DiskName $disk)
* @method static bool remove(\Uwil\Storage\Lib\ValueObjects\StorageFilePath $filePath)
* @method static bool removeFromDisk(\Uwil\Storage\Lib\ValueObjects\StorageFilePath $filePath, \Uwil\Storage\Lib\ValueObjects\DiskName $disk)
*
* @see \Uwil\Storage\Contracts\StorageService
* @see \Uwil\Storage\Lib\StorageServiceImpl

View file

@ -83,16 +83,18 @@ readonly class StorageServiceImpl implements StorageService
}
#[\Override]
public function remove(StorageFilePath $filePath): void
#[\Override]
public function remove(StorageFilePath $filePath): bool
{
$defaultDisk = $this->config->getDefaultDisk();
$this->gateway->deleteFile($defaultDisk, $filePath);
return $this->gateway->deleteFile($defaultDisk, $filePath);
}
#[\Override]
public function removeFromDisk(StorageFilePath $filePath, DiskName $disk): void
public function removeFromDisk(StorageFilePath $filePath, DiskName $disk): bool
{
$this->gateway->deleteFile($disk, $filePath);
return $this->gateway->deleteFile($disk, $filePath);
}
}