Skip to content
This repository has been archived by the owner on Feb 1, 2020. It is now read-only.
/ php-file Public archive

An extension of SplFileObject that uses exceptions.

License

Notifications You must be signed in to change notification settings

kherge-archive/php-file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File

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.

About

An extension of SplFileObject that uses exceptions.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages