From a5db547e7ed5b584ce788a96240c9690cad0c876 Mon Sep 17 00:00:00 2001 From: steevenz Date: Sat, 9 Feb 2019 11:06:47 +0700 Subject: [PATCH] inline docs revisions --- README.md | 18 +-- src/Config/Mimes.php | 2 +- src/Directory.php | 11 +- src/File.php | 2 +- src/Files/Abstracts/AbstractFile.php | 2 +- src/Files/CsvFile.php | 2 +- src/Files/IniFile.php | 4 +- src/Files/JsonFile.php | 4 +- src/Files/XmlFile.php | 4 +- src/Files/ZipFile.php | 4 +- src/Handlers/Downloader.php | 163 +++++++++++++++++++++++++-- src/Handlers/Ftp.php | 4 +- src/Handlers/Uploader.php | 31 ++++- src/System.php | 6 +- src/autoload.php | 2 +- 15 files changed, 210 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 66e04f4..995f7de 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,4 @@ -
- [![O2System Framework](http://o2system.id/assets/img/logo/logo-white-200px.png?logo)](http://o2system.id) -
- -
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/o2system/filesystem/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/o2system/filesystem/?branch=master) [![Build Status](https://scrutinizer-ci.com/g/o2system/filesystem/badges/build.png?b=master)](https://scrutinizer-ci.com/g/o2system/filesystem/build-status/master) @@ -11,8 +6,6 @@ [![Total Downloads](https://poser.pugx.org/o2system/filesystem/downloads)](https://packagist.org/packages/o2system/filesystem) [![License](https://poser.pugx.org/o2system/filesystem/license)](https://packagist.org/packages/o2system/filesystem) -
- # O2System Filesystem O2System Filesystem is an Open Source PHP Convenience Library for reading, writing and appending data from and into files and directories, which is built for working more powerfully with O2System Framework, but it also can be used with other frameworks as a standalone version with limited features. @@ -60,19 +53,12 @@ $downloader->download(); Documentation is available on this repository [wiki](https://github.com/o2system/filesystem/wiki) or visit this repository [github page](https://o2system.github.io/filesystem). ### Ideas and Suggestions -Please kindly mail us at [o2system.framework@gmail.com](mailto:o2system.framework@gmail.com]) +Please kindly mail us at [contact@o2system.id](mailto:contact@o2system.id]) ### Bugs and Issues Please kindly submit your [issues at Github](http://github.com/o2system/filesystem/issues) so we can track all the issues along development and send a [pull request](http://github.com/o2system/filesystem/pulls) to this repository. ### System Requirements -- PHP 7.2+ +- PHP 7.2+ with FileInfo (finfo) extension - [Composer](https://getcomposer.org) - [O2System Kernel](https://github.com/o2system/kernel) - -### Credits -|Role|Name| -|----|----| -|Founder and Lead Projects|[Steeven Andrian Salim](http://steevenz.com)| -|Documentation|[Steeven Andrian Salim](http://steevenz.com) -|Github Pages Designer| [Teguh Rianto](http://teguhrianto.tk) diff --git a/src/Config/Mimes.php b/src/Config/Mimes.php index a8dcec8..bb4cabc 100644 --- a/src/Config/Mimes.php +++ b/src/Config/Mimes.php @@ -1,6 +1,6 @@ filePath diff --git a/src/Handlers/Downloader.php b/src/Handlers/Downloader.php index ce9d633..41897ff 100644 --- a/src/Handlers/Downloader.php +++ b/src/Handlers/Downloader.php @@ -1,6 +1,6 @@ seekStart = ($range[ 0 ] > 0 && $range[ 0 ] < $this->filesize - 1) ? $range[ 0 ] : 0; $this->seekEnd = ($range[ 1 ] > 0 && $range[ 1 ] < $this->filesize && $range[ 1 ] > $this->seekStart) ? $range[ 1 ] : $this->filesize - 1; - $this->seekFilesize = $this->seekEnd - $this->seekStart + 1; + $this->seekFileSize = $this->seekEnd - $this->seekStart + 1; } else { $this->partialRequest = false; $this->seekStart = 0; $this->seekEnd = $this->filesize - 1; - $this->seekFilesize = $this->filesize; + $this->seekFileSize = $this->filesize; } } + // ------------------------------------------------------------------------ + + /** + * Downloader::getMime + * + * @param string $filePath + * + * @return string + */ private function getMime($filePath) { $file = new File($filePath); @@ -136,6 +244,14 @@ private function getMime($filePath) return $mime; } + // ------------------------------------------------------------------------ + + /** + * Downloader::forceDownload + * + * @param string|null $filename + * @param string $filemime + */ public function forceDownload($filename = null, $filemime = 'application/octet-stream') { // Force mime @@ -143,6 +259,13 @@ public function forceDownload($filename = null, $filemime = 'application/octet-s $this->download($filename); } + // ------------------------------------------------------------------------ + + /** + * Downloader::download + * + * @param string|null $filename + */ public function download($filename = null) { $filename = isset($filename) ? $filename : $this->fileinfo[ 'basename' ]; @@ -161,7 +284,7 @@ public function download($filename = null) // Turn off resume capability $this->seekStart = 0; $this->seekEnd = $this->filesize - 1; - $this->seekFilesize = $this->filesize; + $this->seekFileSize = $this->filesize; } } @@ -169,7 +292,7 @@ public function download($filename = null) output() ->sendHeader('Content-Type', $this->filemime) ->sendHeader('Content-Disposition', 'attachment; filename=' . $filename) - ->sendHeader('Content-Length', $this->seekFilesize) + ->sendHeader('Content-Length', $this->seekFileSize) ->sendHeader('Last-Modified', date('D, d M Y H:i:s \G\M\T', $this->lastModified)); // End Headers Stage @@ -198,7 +321,7 @@ public function download($filename = null) // Download According Download Mode if ($this->mode === self::MODE_FILESTREAM) { // Download Data by fopen - $downloadFileBytes = $this->seekFilesize; + $downloadFileBytes = $this->seekFileSize; $downloaded = 0; // goto the position of the first byte to download fseek($this->filedata, $this->seekStart); @@ -233,7 +356,7 @@ public function download($filename = null) fclose($this->filedata); } elseif ($this->mode === self::MODE_DATASTREAM) { // Download Data String - $downloadFileBytes = $this->seekFilesize; + $downloadFileBytes = $this->seekFileSize; $downloaded = 0; $offset = $this->seekStart; @@ -262,13 +385,22 @@ public function download($filename = null) } // Set Downloaded Bytes - $this->downloadedFilesize = $downloaded; + $this->downloadedFileSize = $downloaded; ignore_user_abort($oldUserAbortSetting); // Restore old user abort settings set_time_limit(ini_get('max_execution_time')); // Restore Default script max execution Time exit; } + // ------------------------------------------------------------------------ + + /** + * Downloader::resumeable + * + * @param bool $status + * + * @return static + */ public function resumeable($status = true) { $this->partialRequest = $this->resumeable = ( bool )$status; @@ -276,6 +408,15 @@ public function resumeable($status = true) return $this; } + // ------------------------------------------------------------------------ + + /** + * Downloader::speedLimit + * + * @param int $limit + * + * @return static + */ public function speedLimit($limit) { $limit = intval($limit); diff --git a/src/Handlers/Ftp.php b/src/Handlers/Ftp.php index 04bb436..d758f4c 100644 --- a/src/Handlers/Ftp.php +++ b/src/Handlers/Ftp.php @@ -1,6 +1,6 @@ uploadedFiles = new ArrayIterator(); } + // ------------------------------------------------------------------------ + /** * Uploader::setAllowedMimes * @@ -396,6 +397,15 @@ public function setTargetFilename($filename, $conversionFunction = 'dash') return $this; } + // ------------------------------------------------------------------------ + + /** + * Uploader::validate + * + * @param \O2System\Kernel\Http\Message\UploadFile $file + * + * @return bool + */ protected function validate(UploadFile $file) { /* Validate extension */ @@ -445,13 +455,21 @@ protected function validate(UploadFile $file) return false; } + // ------------------------------------------------------------------------ + + /** + * Uploader::mode + * + * @param \O2System\Kernel\Http\Message\UploadFile $file + * @param $targetPath + */ protected function move(UploadFile $file, $targetPath) { $fileInfo = [ 'name' => pathinfo($targetPath, PATHINFO_BASENAME), 'path' => $targetPath, 'mime' => $file->getFileMime(), - 'size' => $file->getSize() + 'size' => $file->getSize(), ]; $file->moveTo($targetPath); @@ -463,6 +481,13 @@ protected function move(UploadFile $file, $targetPath) } } + // ------------------------------------------------------------------------ + + /** + * Uploader::getUploadedFiles + * + * @return array|\O2System\Spl\Iterators\ArrayIterator + */ public function getUploadedFiles() { return $this->uploadedFiles; diff --git a/src/System.php b/src/System.php index 11b0a8e..0119ece 100644 --- a/src/System.php +++ b/src/System.php @@ -1,6 +1,6 @@