Skip to content

Commit

Permalink
Add Stringable on storage attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
maxhelias committed Jan 7, 2025
1 parent 704c10b commit 1ab5499
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/DirectoryAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace League\Flysystem;

class DirectoryAttributes implements StorageAttributes
class DirectoryAttributes implements StorageAttributes, \Stringable
{
use ProxyArrayAccessToProperties;
private string $type = StorageAttributes::TYPE_DIRECTORY;
Expand Down Expand Up @@ -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);
}
}
7 changes: 6 additions & 1 deletion src/FileAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace League\Flysystem;

class FileAttributes implements StorageAttributes
class FileAttributes implements StorageAttributes, \Stringable
{
use ProxyArrayAccessToProperties;
private string $type = StorageAttributes::TYPE_FILE;
Expand Down Expand Up @@ -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);
}
}
3 changes: 3 additions & 0 deletions src/StorageAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use ArrayAccess;
use JsonSerializable;

/**
* @method string __toString() Stringable interface will be added in 4.0
*/
interface StorageAttributes extends JsonSerializable, ArrayAccess
{
public const ATTRIBUTE_PATH = 'path';
Expand Down

0 comments on commit 1ab5499

Please sign in to comment.