kherge/file

This package is abandoned and no longer maintained. The author suggests using the kherge/file-manager package instead.

An extension of SplFileObject that uses exceptions.

1.3.0 2015-05-08 15:46 UTC

This package is not auto-updated.

Last update: 2021-12-07 01:39:34 UTC


README

SensioLabsInsight Build Status Latest Stable Version Latest Unstable Version Total Downloads

An extension of SplFileObject that uses exceptions.

Usage

You would use this class the exact same way you use SplFileObject, because it is SplFileObject. The only difference is that errors will throw an exception when they occur.

use KHerGe\File\File;

$file = new File('example.txt');
$file->fseek(-1);

/* 
 * Fatal error: Uncaught exception 'KHerGe\File\Exception\FileException' with message 'The file "test.txt" could not be seeked.' in /path/to/file/src/lib/KHerGe/File/Exception/FileException.php on line 157
 *
 * KHerGe\File\Exception\FileException: The file "test.txt" could not be seeked. in /path/to/file/src/lib/KHerGe/File/Exception/FileException.php on line 157
 *
 * Call Stack:
 *     0.0001     248992   1. {main}() /path/to/file/test.php:0
 *     0.0011     382928   2. KHerGe\File\File->fseek() /path/to/file/test.php:6
 */

Exceptions originally thrown by SplFileObject will also be wrapped in the FileException class included with this library.

Requirements

  • PHP >= 5.4

Installation

Via Composer:

$ composer require "kherge/file=dev-master"

I recommend that you install the most recent stable release. You can find one on Packagist, the GitHub releases page, or the tag list in the Git repository.

License

This library is available under the MIT license.