UnableToWriteFile.php 919 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. declare(strict_types=1);
  3. namespace League\Flysystem;
  4. use RuntimeException;
  5. use Throwable;
  6. final class UnableToWriteFile extends RuntimeException implements FilesystemOperationFailed
  7. {
  8. /**
  9. * @var string
  10. */
  11. private $location = '';
  12. /**
  13. * @var string
  14. */
  15. private $reason;
  16. public static function atLocation(string $location, string $reason = '', Throwable $previous = null): UnableToWriteFile
  17. {
  18. $e = new static(rtrim("Unable to write file at location: {$location}. {$reason}"), 0, $previous);
  19. $e->location = $location;
  20. $e->reason = $reason;
  21. return $e;
  22. }
  23. public function operation(): string
  24. {
  25. return FilesystemOperationFailed::OPERATION_WRITE;
  26. }
  27. public function reason(): string
  28. {
  29. return $this->reason;
  30. }
  31. public function location(): string
  32. {
  33. return $this->location;
  34. }
  35. }