From 0857b53bae9ec56c7bfc00a29570a666325a958c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20H=C3=A9lias?= Date: Thu, 29 Aug 2024 15:46:19 +0200 Subject: [PATCH] Add Stringable on storage attributes --- src/DirectoryAttributes.php | 7 ++++++- src/FileAttributes.php | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/DirectoryAttributes.php b/src/DirectoryAttributes.php index 3fe44c1b4..02533c610 100644 --- a/src/DirectoryAttributes.php +++ b/src/DirectoryAttributes.php @@ -4,7 +4,7 @@ namespace League\Flysystem; -class DirectoryAttributes implements StorageAttributes +class DirectoryAttributes implements StorageAttributes, \Stringable { use ProxyArrayAccessToProperties; private string $type = StorageAttributes::TYPE_DIRECTORY; @@ -84,4 +84,9 @@ public function jsonSerialize(): array StorageAttributes::ATTRIBUTE_EXTRA_METADATA => $this->extraMetadata, ]; } + + public function __toString(): string + { + return sprintf('%s(%s)', $this->type, $this->path); + } } diff --git a/src/FileAttributes.php b/src/FileAttributes.php index 42172f8c4..a2be0429a 100644 --- a/src/FileAttributes.php +++ b/src/FileAttributes.php @@ -4,7 +4,7 @@ namespace League\Flysystem; -class FileAttributes implements StorageAttributes +class FileAttributes implements StorageAttributes, \Stringable { use ProxyArrayAccessToProperties; private string $type = StorageAttributes::TYPE_FILE; @@ -97,4 +97,9 @@ public function jsonSerialize(): array StorageAttributes::ATTRIBUTE_EXTRA_METADATA => $this->extraMetadata, ]; } + + public function __toString(): string + { + return sprintf('%s(%s)', $this->type, $this->path); + } }