Skip to content

Commit

Permalink
add-missing-methods-to-filesystem-contract
Browse files Browse the repository at this point in the history
  • Loading branch information
Zack Bundy committed Jul 2, 2024
1 parent d978117 commit 7aee236
Showing 1 changed file with 177 additions and 4 deletions.
181 changes: 177 additions & 4 deletions src/Illuminate/Contracts/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,31 @@ interface Filesystem
*/
const VISIBILITY_PRIVATE = 'private';

/**
* Assert that the given file or directory exists.
*
* @param string|array $path
* @param string|null $content
* @return $this
*/
public function assertExists($path, $content = null);

/**
* Assert that the given file or directory does not exist.
*
* @param string|array $path
* @return $this
*/
public function assertMissing($path);

/**
* Assert that the given directory is empty.
*
* @param string $path
* @return $this
*/
public function assertDirectoryEmpty($path);

/**
* Get the full path to the file that exists at the given relative path.
*
Expand All @@ -34,6 +59,46 @@ public function path($path);
*/
public function exists($path);

/**
* Determine if a file or directory is missing.
*
* @param string $path
* @return bool
*/
public function missing($path);

/**
* Determine if a file exists.
*
* @param string $path
* @return bool
*/
public function fileExists($path);

/**
* Determine if a file is missing.
*
* @param string $path
* @return bool
*/
public function fileMissing($path);

/**
* Determine if a directory exists.
*
* @param string $path
* @return bool
*/
public function directoryExists($path);

/**
* Determine if a directory is missing.
*
* @param string $path
* @return bool
*/
public function directoryMissing($path);

/**
* Get the contents of a file.
*
Expand All @@ -50,13 +115,42 @@ public function get($path);
*/
public function readStream($path);

/**
* Get the contents of a file as decoded JSON.
*
* @param string $path
* @param int $flags
* @return array|null
*/
public function json($path, $flags = 0);

/**
* Create a streamed response for a given file.
*
* @param string $path
* @param string|null $name
* @param array $headers
* @param string|null $disposition
* @return \Symfony\Component\HttpFoundation\StreamedResponse
*/
public function response($path, $name = null, array $headers = [], $disposition = 'inline');

/**
* Create a streamed download response for a given file.
*
* @param string $path
* @param string|null $name
* @return \Symfony\Component\HttpFoundation\StreamedResponse
*/
public function download($path, $name = null, array $headers = []);

/**
* Write the contents of a file.
*
* @param string $path
* @param \Psr\Http\Message\StreamInterface|\Illuminate\Http\File|\Illuminate\Http\UploadedFile|string|resource $contents
* @param mixed $options
* @return bool
* @return string|bool
*/
public function put($path, $contents, $options = []);

Expand Down Expand Up @@ -113,18 +207,20 @@ public function setVisibility($path, $visibility);
*
* @param string $path
* @param string $data
* @param string $separator
* @return bool
*/
public function prepend($path, $data);
public function prepend($path, $data, $separator = PHP_EOL);

/**
* Append to a file.
*
* @param string $path
* @param string $data
* @param string $separator
* @return bool
*/
public function append($path, $data);
public function append($path, $data, $separator = PHP_EOL);

/**
* Delete the file at a given path.
Expand Down Expand Up @@ -160,6 +256,23 @@ public function move($from, $to);
*/
public function size($path);

/**
* Get the checksum for a file.
*
* @return string|false
*
* @throws \League\Flysystem\UnableToProvideChecksum
*/
public function checksum(string $path, array $options = []);

/**
* Get the mime-type of a given file.
*
* @param string $path
* @return string|false
*/
public function mimeType($path);

/**
* Get the file's last modification time.
*
Expand All @@ -168,6 +281,37 @@ public function size($path);
*/
public function lastModified($path);

/**
* Determine if temporary URLs can be generated.
*
* @return bool
*/
public function providesTemporaryUrls();

/**
* Get a temporary URL for the file at the given path.
*
* @param string $path
* @param \DateTimeInterface $expiration
* @param array $options
* @return string
*
* @throws \RuntimeException
*/
public function temporaryUrl($path, $expiration, array $options = []);

/**
* Get a temporary upload URL for the file at the given path.
*
* @param string $path
* @param \DateTimeInterface $expiration
* @param array $options
* @return array
*
* @throws \RuntimeException
*/
public function temporaryUploadUrl($path, $expiration, array $options = []);

/**
* Get an array of all files in a directory.
*
Expand Down Expand Up @@ -195,7 +339,7 @@ public function allFiles($directory = null);
public function directories($directory = null, $recursive = false);

/**
* Get all (recursive) of the directories within a given directory.
* Get all the directories within a given directory (recursive).
*
* @param string|null $directory
* @return array
Expand All @@ -217,4 +361,33 @@ public function makeDirectory($path);
* @return bool
*/
public function deleteDirectory($directory);

/**
* Get the Flysystem driver.
*
* @return \League\Flysystem\FilesystemOperator
*/
public function getDriver();

/**
* Get the Flysystem adapter.
*
* @return \League\Flysystem\FilesystemAdapter
*/
public function getAdapter();

/**
* Get the configuration values.
*
* @return array
*/
public function getConfig();

/**
* Define a custom temporary URL builder callback.
*
* @param \Closure $callback
* @return void
*/
public function buildTemporaryUrlsUsing(Closure $callback);
}

0 comments on commit 7aee236

Please sign in to comment.