UnableToSetVisibility.php 981 B

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