diff --git a/README.md b/README.md index 9ffab47..f1d70b7 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Requirements: - Filesystem operations across core modules. - Mount support with scheme paths (`name://path`) and default filesystem support for relative paths. - Config-driven storage bootstrap via `StorageFactory` for local/custom/adapter-based filesystems. -- Unified entry facade via `Infocyph\Pathwise\File` for file/dir/processors/storage/tooling. +- Unified entry facade via `Infocyph\Pathwise\PathwiseFacade` for file/dir/processors/storage/tooling. - Advanced file APIs: checksum verification, visibility controls, URL passthrough (`publicUrl`, `temporaryUrl`). - Directory automation: sync with diff report, recursive copy/move/delete, mounted-path ZIP/unzip bridging. - Upload/download pipelines: chunked/resumable uploads, validation profiles (image/video/document), extension allow/deny controls, strict MIME/signature checks, upload-id safety validation, malware-scan hook, secure download metadata + range handling. @@ -138,20 +138,20 @@ StorageFactory::mount('tenant', [ ]); ``` -## **Unified File Facade** +## **Unified Pathwise Facade** Use a single entry point when you want fewer direct class imports. ```php -use Infocyph\Pathwise\File; +use Infocyph\Pathwise\PathwiseFacade; -$entry = File::at('/tmp/example.txt'); +$entry = PathwiseFacade::at('/tmp/example.txt'); $entry->file()->create('hello')->append("\nworld"); -$upload = File::upload(); -$download = File::download(); +$upload = PathwiseFacade::upload(); +$download = PathwiseFacade::download(); -File::mountStorage('assets', ['driver' => 'local', 'root' => '/srv/assets']); +PathwiseFacade::mountStorage('assets', ['driver' => 'local', 'root' => '/srv/assets']); ``` ## **FileManager** diff --git a/docs/capabilities.rst b/docs/capabilities.rst index 24109a1..4b5929b 100644 --- a/docs/capabilities.rst +++ b/docs/capabilities.rst @@ -14,12 +14,12 @@ Pathwise combines two layers: Primary Modules --------------- -Unified Facade (``Infocyph\Pathwise\File``) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Unified Facade (``Infocyph\Pathwise\PathwiseFacade``) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Class: -* ``File`` +* ``PathwiseFacade`` What you get: diff --git a/docs/file-facade.rst b/docs/file-facade.rst index 5089933..651d676 100644 --- a/docs/file-facade.rst +++ b/docs/file-facade.rst @@ -1,9 +1,9 @@ -Unified File Facade -=================== +Unified Pathwise Facade +======================= Namespace: ``Infocyph\Pathwise`` -Pathwise provides ``File`` as a convenience facade when you want one entry +Pathwise provides ``PathwiseFacade`` as a convenience facade when you want one entry point instead of importing many classes directly. Use this when: @@ -21,9 +21,9 @@ Path-Bound Access .. code-block:: php - use Infocyph\Pathwise\File; + use Infocyph\Pathwise\PathwiseFacade; - $entry = File::at('/tmp/demo.txt'); + $entry = PathwiseFacade::at('/tmp/demo.txt'); $entry->file()->create('hello')->append("\nworld"); @@ -43,11 +43,11 @@ Directory + Compression via Same Entry .. code-block:: php - use Infocyph\Pathwise\File; + use Infocyph\Pathwise\PathwiseFacade; - File::at('/tmp/source')->directory()->create(); + PathwiseFacade::at('/tmp/source')->directory()->create(); - File::at('/tmp/archive.zip') + PathwiseFacade::at('/tmp/archive.zip') ->compression(true) ->compress('/tmp/source') ->save(); @@ -57,39 +57,39 @@ Static Gateways .. code-block:: php - use Infocyph\Pathwise\File; + use Infocyph\Pathwise\PathwiseFacade; - $upload = File::upload(); - $download = File::download(); - $policy = File::policy(); - $queue = File::queue('/tmp/jobs.json'); - $audit = File::audit('/tmp/audit.jsonl'); + $upload = PathwiseFacade::upload(); + $download = PathwiseFacade::download(); + $policy = PathwiseFacade::policy(); + $queue = PathwiseFacade::queue('/tmp/jobs.json'); + $audit = PathwiseFacade::audit('/tmp/audit.jsonl'); Storage from Facade ------------------- -``File`` delegates storage creation/mounting to ``StorageFactory``. +``PathwiseFacade`` delegates storage creation/mounting to ``StorageFactory``. .. code-block:: php - use Infocyph\Pathwise\File; + use Infocyph\Pathwise\PathwiseFacade; - File::mountStorage('assets', [ + PathwiseFacade::mountStorage('assets', [ 'driver' => 'local', 'root' => '/srv/storage/assets', ]); // For other adapters, pass adapter/constructor config: - // File::mountStorage('s3', ['driver' => 's3', 'adapter' => $adapter]); + // PathwiseFacade::mountStorage('s3', ['driver' => 's3', 'adapter' => $adapter]); Operational Tooling from Facade ------------------------------- Available helpers: -* ``File::retain(...)`` -> ``RetentionManager`` -* ``File::index(...)`` / ``File::duplicates(...)`` / ``File::deduplicate(...)`` -> ``ChecksumIndexer`` -* ``File::snapshot(...)`` / ``File::diffSnapshots(...)`` / ``File::watch(...)`` -> ``FileWatcher`` +* ``PathwiseFacade::retain(...)`` -> ``RetentionManager`` +* ``PathwiseFacade::index(...)`` / ``PathwiseFacade::duplicates(...)`` / ``PathwiseFacade::deduplicate(...)`` -> ``ChecksumIndexer`` +* ``PathwiseFacade::snapshot(...)`` / ``PathwiseFacade::diffSnapshots(...)`` / ``PathwiseFacade::watch(...)`` -> ``FileWatcher`` See also: diff --git a/docs/installation.rst b/docs/installation.rst index 879cd90..0d8b26a 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -41,12 +41,12 @@ See ``storage-adapters`` for setup patterns. Where to Use First ------------------ -If you are evaluating Pathwise, start with the unified ``File`` facade, then +If you are evaluating Pathwise, start with the unified ``PathwiseFacade`` facade, then drop down to direct module classes as needed. .. code-block:: php - use Infocyph\Pathwise\File; + use Infocyph\Pathwise\PathwiseFacade; - $ops = File::at('/tmp/example.txt')->file(); + $ops = PathwiseFacade::at('/tmp/example.txt')->file(); $ops->create('initial')->update('updated'); diff --git a/docs/overview.rst b/docs/overview.rst index 1c1dafa..ac7b578 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -15,7 +15,7 @@ It focuses on three layers: Main namespaces: -* ``Infocyph\Pathwise`` (unified ``File`` facade) +* ``Infocyph\Pathwise`` (unified ``PathwiseFacade`` facade) * ``Infocyph\Pathwise\FileManager`` * ``Infocyph\Pathwise\DirectoryManager`` * ``Infocyph\Pathwise\StreamHandler`` @@ -37,14 +37,14 @@ Quick Start .. code-block:: php - use Infocyph\Pathwise\File; + use Infocyph\Pathwise\PathwiseFacade; - File::at('/tmp/demo.txt') + PathwiseFacade::at('/tmp/demo.txt') ->file() ->create('hello') ->append("\nworld"); - $report = File::at('/tmp/source') + $report = PathwiseFacade::at('/tmp/source') ->directory() ->syncTo('/tmp/backup', deleteOrphans: true); diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 149ae23..de760a6 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -15,9 +15,9 @@ This quickstart shows the fastest way to understand what Pathwise can do. .. code-block:: php - use Infocyph\Pathwise\File; + use Infocyph\Pathwise\PathwiseFacade; - $file = File::at('/tmp/example.txt')->file(); + $file = PathwiseFacade::at('/tmp/example.txt')->file(); $file->create("v1\n") ->append("v2\n") ->writeAndVerify("v3\n", 'sha256'); diff --git a/src/File.php b/src/PathwiseFacade.php similarity index 98% rename from src/File.php rename to src/PathwiseFacade.php index a5a8411..f6b9158 100644 --- a/src/File.php +++ b/src/PathwiseFacade.php @@ -21,7 +21,7 @@ use Infocyph\Pathwise\Utils\PathHelper; use League\Flysystem\FilesystemOperator; -final class File +final class PathwiseFacade { /** * Constructor to initialize the file path. @@ -37,7 +37,7 @@ public function __construct(private string $path) * Create a new instance at the given path. * * @param string $path The path to the file or directory. - * @return self A new File instance. + * @return self A new facade instance. */ public static function at(string $path): self { @@ -116,7 +116,7 @@ public static function duplicates(string $directory, string $algorithm = 'sha256 * Alias for at() - create a new instance at the given path. * * @param string $path The path to the file or directory. - * @return self A new File instance. + * @return self A new facade instance. */ public static function from(string $path): self { diff --git a/tests/Feature/FileFacadeTest.php b/tests/Feature/FileFacadeTest.php index 9976b1a..1440550 100644 --- a/tests/Feature/FileFacadeTest.php +++ b/tests/Feature/FileFacadeTest.php @@ -1,6 +1,6 @@ workspace . DIRECTORY_SEPARATOR . 'sample.txt'; - $entry = File::at($filePath); + $entry = PathwiseFacade::at($filePath); $entry->file()->create("line-1\n"); @@ -52,9 +52,9 @@ $zipPath = $this->workspace . DIRECTORY_SEPARATOR . 'archive.zip'; $extractDir = $this->workspace . DIRECTORY_SEPARATOR . 'extract'; - File::at($sourceDir)->directory()->create(); - File::at($zipPath)->compression(true)->compress($sourceDir)->save(); - File::at($zipPath)->compression()->decompress($extractDir)->save(); + PathwiseFacade::at($sourceDir)->directory()->create(); + PathwiseFacade::at($zipPath)->compression(true)->compress($sourceDir)->save(); + PathwiseFacade::at($zipPath)->compression()->decompress($extractDir)->save(); expect(FlysystemHelper::fileExists($zipPath))->toBeTrue() ->and(FlysystemHelper::fileExists($extractDir . DIRECTORY_SEPARATOR . 'a.txt'))->toBeTrue() @@ -65,41 +65,41 @@ $root = $this->workspace . DIRECTORY_SEPARATOR . 'storage'; mkdir($root, 0755, true); - File::mountStorage('facade', [ + PathwiseFacade::mountStorage('facade', [ 'driver' => 'local', 'root' => $root, ]); FlysystemHelper::write('facade://data/file.txt', 'hello'); - $upload = File::upload(); - $download = File::download(); - $policy = File::policy()->allow('*', '*'); + $upload = PathwiseFacade::upload(); + $download = PathwiseFacade::download(); + $policy = PathwiseFacade::policy()->allow('*', '*'); $queueFile = $this->workspace . DIRECTORY_SEPARATOR . 'queue' . DIRECTORY_SEPARATOR . 'jobs.json'; - $queue = File::queue($queueFile); + $queue = PathwiseFacade::queue($queueFile); $queue->enqueue('example', ['id' => 1], 10); $stats = $queue->stats(); $auditFile = $this->workspace . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR . 'audit.jsonl'; - $audit = File::audit($auditFile); + $audit = PathwiseFacade::audit($auditFile); $audit->log('facade.test', ['ok' => true]); $watchPath = $this->workspace . DIRECTORY_SEPARATOR . 'watch.txt'; file_put_contents($watchPath, 'v1'); - $snapshotA = File::snapshot($watchPath); + $snapshotA = PathwiseFacade::snapshot($watchPath); file_put_contents($watchPath, 'v22'); - $snapshotB = File::snapshot($watchPath); - $diff = File::diffSnapshots($snapshotA, $snapshotB); + $snapshotB = PathwiseFacade::snapshot($watchPath); + $diff = PathwiseFacade::diffSnapshots($snapshotA, $snapshotB); $dupDir = $this->workspace . DIRECTORY_SEPARATOR . 'dups'; mkdir($dupDir, 0755, true); file_put_contents($dupDir . DIRECTORY_SEPARATOR . 'a.txt', 'dup'); file_put_contents($dupDir . DIRECTORY_SEPARATOR . 'b.txt', 'dup'); - $index = File::index($dupDir); - $duplicates = File::duplicates($dupDir); + $index = PathwiseFacade::index($dupDir); + $duplicates = PathwiseFacade::duplicates($dupDir); - $retention = File::retain($this->workspace . DIRECTORY_SEPARATOR . 'empty-retention'); + $retention = PathwiseFacade::retain($this->workspace . DIRECTORY_SEPARATOR . 'empty-retention'); expect($upload)->toBeInstanceOf(\Infocyph\Pathwise\StreamHandler\UploadProcessor::class) ->and($download)->toBeInstanceOf(\Infocyph\Pathwise\StreamHandler\DownloadProcessor::class)