Skip to content

Commit 1ab5499

Browse files
committed
Add Stringable on storage attributes
1 parent 704c10b commit 1ab5499

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/DirectoryAttributes.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace League\Flysystem;
66

7-
class DirectoryAttributes implements StorageAttributes
7+
class DirectoryAttributes implements StorageAttributes, \Stringable
88
{
99
use ProxyArrayAccessToProperties;
1010
private string $type = StorageAttributes::TYPE_DIRECTORY;
@@ -84,4 +84,9 @@ public function jsonSerialize(): array
8484
StorageAttributes::ATTRIBUTE_EXTRA_METADATA => $this->extraMetadata,
8585
];
8686
}
87+
88+
public function __toString(): string
89+
{
90+
return sprintf('%s(%s)', $this->type, $this->path);
91+
}
8792
}

src/FileAttributes.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace League\Flysystem;
66

7-
class FileAttributes implements StorageAttributes
7+
class FileAttributes implements StorageAttributes, \Stringable
88
{
99
use ProxyArrayAccessToProperties;
1010
private string $type = StorageAttributes::TYPE_FILE;
@@ -97,4 +97,9 @@ public function jsonSerialize(): array
9797
StorageAttributes::ATTRIBUTE_EXTRA_METADATA => $this->extraMetadata,
9898
];
9999
}
100+
101+
public function __toString(): string
102+
{
103+
return sprintf('%s(%s)', $this->type, $this->path);
104+
}
100105
}

src/StorageAttributes.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
use ArrayAccess;
88
use JsonSerializable;
99

10+
/**
11+
* @method string __toString() Stringable interface will be added in 4.0
12+
*/
1013
interface StorageAttributes extends JsonSerializable, ArrayAccess
1114
{
1215
public const ATTRIBUTE_PATH = 'path';

0 commit comments

Comments
 (0)