(StorageAdapterInterface $storage, string $destDir, string $fileName)
| 380 | } |
| 381 | |
| 382 | private static function getUniqueFileNameForAdapter(StorageAdapterInterface $storage, string $destDir, string $fileName): string |
| 383 | { |
| 384 | $fullPath = $destDir . $fileName; |
| 385 | clearstatcache(true, $fullPath); |
| 386 | if ($storage->stat($fullPath) === null) { |
| 387 | return $fileName; |
| 388 | } |
| 389 | $basename = pathinfo($fileName, PATHINFO_FILENAME); |
| 390 | $extension = pathinfo($fileName, PATHINFO_EXTENSION); |
| 391 | $counter = 1; |
| 392 | do { |
| 393 | $newName = $basename . " (" . $counter . ")" . ($extension ? "." . $extension : ""); |
| 394 | $newFullPath = $destDir . $newName; |
| 395 | clearstatcache(true, $newFullPath); |
| 396 | $counter++; |
| 397 | } while ($storage->stat($destDir . $newName) !== null); |
| 398 | return $newName; |
| 399 | } |
| 400 | |
| 401 | private static function adapterErrorDetail(StorageAdapterInterface $storage): string |
| 402 | { |
no test coverage detected