2017 © Pedro Peláez
 

library file-object-plus

A simple extension of the PHP \SplFileObject class

image

dcarbone/file-object-plus

A simple extension of the PHP \SplFileObject class

  • Tuesday, January 30, 2018
  • by dcarbone
  • Repository
  • 1 Watchers
  • 0 Stars
  • 414 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 3 % Grown

The README.md

file-object-plus

A simple extension of the PHP class SplFileObject, (*1)

Build status: Build Status, (*2)

Basics:

This class is a very simple extension of the base PHP SplFileObject. As such, it has all the same functionality as the base class with a few minor additions., (*3)

Countable Interface

I have implemented the Countable interface into this class. It utilizes my FileHelper helper class to determine the count, (*4)

To use, simply execute:, (*5)

$fileObject = new DCarbone\FileObjectPlus('myfile.txt');
$count = count($fileObject);
echo $count;

To count lines that contain a term, execute:, (*6)

$fileObject = new DCarbone\FileObjectPlus('myfile.txt');
$count = $fileObject->countLinesContaining('my term');
echo $count;

Pagination

This class also implements some very simple pagination methods, modeled closely to how you would specify returning a portion of a database table., (*7)

To get a portion of a file irrespective of line content:, (*8)

$fileObject = new DCarbone\FileObjectPlus('myfile.txt');
$offset = 0;
$limit = 25;
$lines = $fileObject->paginateLines($offset, $limit);
var_dump($lines);

By default, blank lines are also returned. You may alternatively ignore these by passing in 4 parameters:, (*9)

$fileObject = new \DCarbone\FileObjectPlus('myfile.txt');
$offset = 0;
$limit = 25;
$search = null;
$includeEmpty = false;
$lines = $fileObject->paginateLines($offset, $limit, $search, $includeEmpty);
var_dump($lines);

If you wish to paginate through a file only matching lines that contain a certain term:, (*10)

$fileObject = new \DCarbone\FileObjectPlus('myfile.txt');
$offset = 0;
$limit = 25;
$search = 'my term';
$lines = $fileObject->paginateLines($offset, $limit, $search);

Note: When searching, the fourth parameter is ignored, (*11)

Note: Both pagination functions currently reset the underlying SplFileObject's internal line pointer., (*12)

The Versions

30/01 2018

dev-master

9999999-dev https://github.com/dcarbone/file-object-plus

A simple extension of the PHP \SplFileObject class

  Sources   Download

GPLv3 MPL-2.0

The Requires

 

The Development Requires

by Daniel Carbone

file php search pagination splfileobject file iterator

30/01 2018

0.4.0

0.4.0.0 https://github.com/dcarbone/file-object-plus

A simple extension of the PHP \SplFileObject class

  Sources   Download

MPL-2.0

The Requires

 

The Development Requires

by Daniel Carbone

file php search pagination splfileobject file iterator

30/10 2015

0.3.0

0.3.0.0 https://github.com/dcarbone/file-object-plus

A simple extension of the PHP \SplFileObject class

  Sources   Download

GPLv3

The Requires

 

The Development Requires

by Daniel Carbone

file php search pagination splfileobject file iterator

29/10 2015

0.2.0

0.2.0.0 https://github.com/dcarbone/file-object-plus

A simple extension of the PHP \SplFileObject class

  Sources   Download

GPLv3

The Requires

 

The Development Requires

by Daniel Carbone

file php search pagination splfileobject file iterator

07/10 2014

0.1.5

0.1.5.0 https://github.com/dcarbone/file-object-plus

A simple extension of the PHP \SplFileObject class

  Sources   Download

GPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

by Daniel Carbone

file php search pagination splfileobject file iterator

18/08 2014

0.1.4

0.1.4.0 https://github.com/dcarbone/file-object-plus

A simple extension of the PHP \SplFileObject class

  Sources   Download

GPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

by Daniel Carbone

file php search pagination splfileobject file iterator

18/08 2014

0.1.3

0.1.3.0 https://github.com/dcarbone/file-object-plus

A simple extension of the PHP \SplFileObject class

  Sources   Download

GPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

by Daniel Carbone

file php search pagination splfileobject file iterator

17/08 2014

0.1.2

0.1.2.0 https://github.com/dcarbone/file-object-plus

A simple extension of the PHP \SplFileObject class

  Sources   Download

GPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

by Daniel Carbone

file php search pagination splfileobject file iterator

17/08 2014

0.1.1

0.1.1.0 https://github.com/dcarbone/file-object-plus

A simple extension of the PHP \SplFileObject class

  Sources   Download

GPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

by Daniel Carbone

file php search pagination splfileobject file iterator

17/08 2014

0.1.0

0.1.0.0 https://github.com/dcarbone/file-object-plus

A simple extension of the PHP \SplFileObject class

  Sources   Download

GPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

by Daniel Carbone

file php search pagination splfileobject file iterator