trait FilesystemAdapterDecorator

Traits

Decorates the underlying filesystem by wrapping all calls to it with tracing.

Properties

protected Filesystem $filesystem from  FilesystemDecorator
protected array $defaultData from  FilesystemDecorator
protected bool $recordSpans from  FilesystemDecorator
protected bool $recordBreadcrumbs from  FilesystemDecorator

Methods

mixed
withSentry(string $method, array $args, string|null $description, array $data)

Execute the method on the underlying filesystem and wrap it with tracing and log a breadcrumb.

string
path(string $path)

Get the full path to the file that exists at the given relative path.

bool
exists(string $path)

Determine if a file or directory exists.

bool
fileExists(string $path)

Determine if a file exists.

bool
directoryExists(string $path)

Determine if a directory exists.

string|null
get(string $path)

Get the contents of a file.

mixed
readStream(string $path)

Get a resource to read the file.

mixed
readStreamRange(string $path, int|null $start, int|null $end)

Get a resource to read part of the file.

bool|string
put(string $path, mixed $contents, mixed $options = [])

Write the contents of a file.

false|string
putFile(string|File|UploadedFile $path, array|string|File|UploadedFile|null $file = null, mixed $options = [])

Store the uploaded file on the disk.

false|string
putFileAs(string|File|UploadedFile $path, array|string|File|UploadedFile|null $file, array|string|null $name = null, mixed $options = [])

Store the uploaded file on the disk with a given name.

bool
writeStream(string $path, mixed $resource, array $options = [])

Write a new file using a stream.

string
getVisibility(string $path)

Get the visibility for the given path.

bool
setVisibility(string $path, string $visibility)

Set the visibility for the given path.

bool
prepend(string $path, string $data, string $separator = PHP_EOL)

Prepend to a file.

bool
append(string $path, string $data, string $separator = PHP_EOL)

Append to a file.

bool
delete(array|string $paths)

Delete the file at a given path.

bool
copy(string $from, string $to)

Copy a file to a new location.

bool
move(string $from, string $to)

Move a file to a new location.

bool
copyToDisk(Filesystem|string|UnitEnum $disk, string $from, string|null $to = null)

Copy a file to another disk.

bool
moveToDisk(Filesystem|string|UnitEnum $disk, string $from, string|null $to = null)

Move a file to another disk.

bool
transferToDisk(string $method, Filesystem|string|UnitEnum $disk, string $from, string|null $to)

Trace a transfer while preserving the wrapped disk's identity check.

int
size(string $path)

Get the file size of a given file.

int
lastModified(string $path)

Get the file's last modification time.

array
files(string|null $directory = null, bool $recursive = false)

Get an array of all files in a directory.

array
allFiles(string|null $directory = null)

Get all of the files from the given directory recursively.

array
directories(string|null $directory = null, bool $recursive = false)

Get all of the directories within a given directory.

array
allDirectories(string|null $directory = null)

Get all of the directories recursively.

bool
makeDirectory(string $path)

Create a directory.

bool
deleteDirectory(string $directory)

Recursively delete a directory.

getFilesystem()

Get the wrapped filesystem.

bool
invalidatePool()

Invalidate the wrapped filesystem's pool when supported.

array
getDescriptionAndDataForPathOrPaths(array|string $pathOrPaths)

Get the description and data for one or more paths.

mixed
__call(string $name, array $arguments)

Dynamically proxy calls to the wrapped filesystem.

string
url(string $path)

Get the URL for the file at the given path.

assertExists(array|string $path, string|null $content = null)

Assert that the given file or directory exists.

assertMissing(array|string $path)

Assert that the given file or directory does not exist.

assertDirectoryEmpty(string $path)

Assert that the given directory is empty.

false|string
checksum(string $path, array $options = [])

Get the checksum for a file.

false|string
mimeType(string $path)

Get the mime-type of a given file.

bool
providesTemporaryUrls()

Determine if temporary URLs can be generated.

bool
providesTemporaryUploadUrls()

Determine if temporary upload URLs can be generated.

string
temporaryUrl(string $path, DateTimeInterface $expiration, array $options = [])

Get a temporary URL for the file at the given path.

array|string
temporaryUploadUrl(string $path, DateTimeInterface $expiration, array $options = [])

Get a temporary upload URL for the file at the given path.

void
buildTemporaryUrlsUsing(Closure|null $callback)

Define a custom temporary URL builder callback.

void
buildTemporaryUploadUrlsUsing(Closure|null $callback)

Define a custom temporary upload URL builder callback.

Details

protected mixed withSentry(string $method, array $args, string|null $description, array $data)

Execute the method on the underlying filesystem and wrap it with tracing and log a breadcrumb.

Parameters

string $method
array $args
string|null $description
array $data

Return Value

mixed

string path(string $path)

Get the full path to the file that exists at the given relative path.

Parameters

string $path

Return Value

string

bool exists(string $path)

Determine if a file or directory exists.

Parameters

string $path

Return Value

bool

bool fileExists(string $path)

Determine if a file exists.

Parameters

string $path

Return Value

bool

in FilesystemDecorator at line 104
bool directoryExists(string $path)

Determine if a directory exists.

Parameters

string $path

Return Value

bool

in FilesystemDecorator at line 112
string|null get(string $path)

Get the contents of a file.

Parameters

string $path

Return Value

string|null

in FilesystemDecorator at line 122
mixed readStream(string $path)

Get a resource to read the file.

Parameters

string $path

Return Value

mixed

in FilesystemDecorator at line 132
mixed readStreamRange(string $path, int|null $start, int|null $end)

Get a resource to read part of the file.

Parameters

string $path
int|null $start
int|null $end

Return Value

mixed

in FilesystemDecorator at line 142
bool|string put(string $path, mixed $contents, mixed $options = [])

Write the contents of a file.

Parameters

string $path
mixed $contents
mixed $options

Return Value

bool|string

in FilesystemDecorator at line 152
false|string putFile(string|File|UploadedFile $path, array|string|File|UploadedFile|null $file = null, mixed $options = [])

Store the uploaded file on the disk.

Parameters

string|File|UploadedFile $path
array|string|File|UploadedFile|null $file
mixed $options

Return Value

false|string

in FilesystemDecorator at line 165
false|string putFileAs(string|File|UploadedFile $path, array|string|File|UploadedFile|null $file, array|string|null $name = null, mixed $options = [])

Store the uploaded file on the disk with a given name.

Parameters

string|File|UploadedFile $path
array|string|File|UploadedFile|null $file
array|string|null $name
mixed $options

Return Value

false|string

in FilesystemDecorator at line 181
bool writeStream(string $path, mixed $resource, array $options = [])

Write a new file using a stream.

Parameters

string $path
mixed $resource
array $options

Return Value

bool

in FilesystemDecorator at line 189
string getVisibility(string $path)

Get the visibility for the given path.

Parameters

string $path

Return Value

string

in FilesystemDecorator at line 197
bool setVisibility(string $path, string $visibility)

Set the visibility for the given path.

Parameters

string $path
string $visibility

Return Value

bool

in FilesystemDecorator at line 205
bool prepend(string $path, string $data, string $separator = PHP_EOL)

Prepend to a file.

Parameters

string $path
string $data
string $separator

Return Value

bool

in FilesystemDecorator at line 215
bool append(string $path, string $data, string $separator = PHP_EOL)

Append to a file.

Parameters

string $path
string $data
string $separator

Return Value

bool

in FilesystemDecorator at line 225
bool delete(array|string $paths)

Delete the file at a given path.

Parameters

array|string $paths

Return Value

bool

in FilesystemDecorator at line 235
bool copy(string $from, string $to)

Copy a file to a new location.

Parameters

string $from
string $to

Return Value

bool

in FilesystemDecorator at line 243
bool move(string $from, string $to)

Move a file to a new location.

Parameters

string $from
string $to

Return Value

bool

in FilesystemDecorator at line 251
bool copyToDisk(Filesystem|string|UnitEnum $disk, string $from, string|null $to = null)

Copy a file to another disk.

Parameters

Filesystem|string|UnitEnum $disk
string $from
string|null $to

Return Value

bool

in FilesystemDecorator at line 259
bool moveToDisk(Filesystem|string|UnitEnum $disk, string $from, string|null $to = null)

Move a file to another disk.

Parameters

Filesystem|string|UnitEnum $disk
string $from
string|null $to

Return Value

bool

in FilesystemDecorator at line 267
protected bool transferToDisk(string $method, Filesystem|string|UnitEnum $disk, string $from, string|null $to)

Trace a transfer while preserving the wrapped disk's identity check.

Parameters

string $method
Filesystem|string|UnitEnum $disk
string $from
string|null $to

Return Value

bool

in FilesystemDecorator at line 289
int size(string $path)

Get the file size of a given file.

Parameters

string $path

Return Value

int

in FilesystemDecorator at line 297
int lastModified(string $path)

Get the file's last modification time.

Parameters

string $path

Return Value

int

in FilesystemDecorator at line 305
array files(string|null $directory = null, bool $recursive = false)

Get an array of all files in a directory.

Parameters

string|null $directory
bool $recursive

Return Value

array

in FilesystemDecorator at line 313
array allFiles(string|null $directory = null)

Get all of the files from the given directory recursively.

Parameters

string|null $directory

Return Value

array

in FilesystemDecorator at line 321
array directories(string|null $directory = null, bool $recursive = false)

Get all of the directories within a given directory.

Parameters

string|null $directory
bool $recursive

Return Value

array

in FilesystemDecorator at line 329
array allDirectories(string|null $directory = null)

Get all of the directories recursively.

Parameters

string|null $directory

Return Value

array

in FilesystemDecorator at line 337
bool makeDirectory(string $path)

Create a directory.

Parameters

string $path

Return Value

bool

in FilesystemDecorator at line 345
bool deleteDirectory(string $directory)

Recursively delete a directory.

Parameters

string $directory

Return Value

bool

in FilesystemDecorator at line 353
Filesystem getFilesystem()

Get the wrapped filesystem.

Return Value

Filesystem

in FilesystemDecorator at line 361
bool invalidatePool()

Invalidate the wrapped filesystem's pool when supported.

Return Value

bool

in FilesystemDecorator at line 372
protected array getDescriptionAndDataForPathOrPaths(array|string $pathOrPaths)

Get the description and data for one or more paths.

Parameters

array|string $pathOrPaths

Return Value

array

in FilesystemDecorator at line 388
mixed __call(string $name, array $arguments)

Dynamically proxy calls to the wrapped filesystem.

Parameters

string $name
array $arguments

Return Value

mixed

string url(string $path)

Get the URL for the file at the given path.

Parameters

string $path

Return Value

string

at line 18
FilesystemAdapterDecorator assertExists(array|string $path, string|null $content = null)

Assert that the given file or directory exists.

Parameters

array|string $path
string|null $content

Return Value

FilesystemAdapterDecorator

at line 32
FilesystemAdapterDecorator assertMissing(array|string $path)

Assert that the given file or directory does not exist.

Parameters

array|string $path

Return Value

FilesystemAdapterDecorator

at line 44
FilesystemAdapterDecorator assertDirectoryEmpty(string $path)

Assert that the given directory is empty.

Parameters

string $path

Return Value

FilesystemAdapterDecorator

at line 54
false|string checksum(string $path, array $options = [])

Get the checksum for a file.

Parameters

string $path
array $options

Return Value

false|string

at line 62
false|string mimeType(string $path)

Get the mime-type of a given file.

Parameters

string $path

Return Value

false|string

at line 70
bool providesTemporaryUrls()

Determine if temporary URLs can be generated.

Return Value

bool

at line 78
bool providesTemporaryUploadUrls()

Determine if temporary upload URLs can be generated.

Return Value

bool

at line 86
string temporaryUrl(string $path, DateTimeInterface $expiration, array $options = [])

Get a temporary URL for the file at the given path.

Parameters

string $path
DateTimeInterface $expiration
array $options

Return Value

string

at line 94
array|string temporaryUploadUrl(string $path, DateTimeInterface $expiration, array $options = [])

Get a temporary upload URL for the file at the given path.

Parameters

string $path
DateTimeInterface $expiration
array $options

Return Value

array|string

at line 106
void buildTemporaryUrlsUsing(Closure|null $callback)

Define a custom temporary URL builder callback.

This changes the wrapped adapter. On a cached disk, the callback persists for the worker lifetime and runs on every subsequent temporary URL generation for that disk.

Parameters

Closure|null $callback

Return Value

void

at line 118
void buildTemporaryUploadUrlsUsing(Closure|null $callback)

Define a custom temporary upload URL builder callback.

This changes the wrapped adapter. On a cached disk, the callback persists for the worker lifetime and runs on every subsequent temporary upload URL generation for that disk.

Parameters

Closure|null $callback

Return Value

void