2017 © Pedro Peláez
 

library loop-tracker

A simple PHP class for tracking the status of a loop.

image

jepster/loop-tracker

A simple PHP class for tracking the status of a loop.

  • Sunday, June 28, 2015
  • by jepster
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

LoopTracker

A simple PHP class to output the status of a loop into the standard out via the "echo"-function. The functionality is tested by PHPUnit., (*1)

LoopTracker allows you to track the progress via a very handy call:, (*2)

LoopTracker::track('My loop title', count($total_items_to_iterate));

There's also a third parameter to pass, which sets the numbers of items which will be processed by one iteration. Default is "1"., (*3)

So if you process 20 items per iteration, use the following line:, (*4)

LoopTracker::track('My loop title', count($total_items_to_iterate), 20);

The full code of the loop looks like so (copied from the PHPUnit testing):, (*5)

for ($i = 0; $i <= 100; ++$i) {
    LoopTracker::track('One Item per Iteration Loop Tracker PHPUnit Test', 100);
}

Of course you can do different things in your loop, than just track the loop., (*6)

Afterwards you get informative messages into your console output as such:, (*7)

Processing "One Item per Iteration Loop Tracker PHPUnit Test"
1 of 100 / 1% / elapsed seconds: 0

Processing "One Item per Iteration Loop Tracker PHPUnit Test"
2 of 100 / 2% / elapsed seconds: 0

...

Processing "One Item per Iteration Loop Tracker PHPUnit Test"
99 of 100 / 99% / elapsed seconds: 0

Processing "One Item per Iteration Loop Tracker PHPUnit Test"
100 of 100 / 100% / elapsed seconds: 0
----------------------
Finish at: 16:45:15 - 28.06.15
Start was: 16:45:15 - 28.06.15
----------------------

Getting Started

LoopTracker can be installed with Composer or downloaded manually., (*8)

With Composer

If you're already using Composer, just add jepster/loop-tracker to your composer.json file. LoopTracker works with Composer's autoloader out of the bat., (*9)

{
    "require": {
        "jepster/loop-tracker": "dev-master"
    }
}

Manually

If you aren't using Composer, you just need to include lib/LoopTracker.php in your script., (*10)

require_once("path/to/LoopTracker.php");

Testing via PHPUnit

You need PHPUnit installed to run the tests. Configuration is defined in phpunit.xml.dist. Running the tests is easy:, (*11)

phpunit

The Versions

28/06 2015

dev-master

9999999-dev https://github.com/jepster/LoopTracker

A simple PHP class for tracking the status of a loop.

  Sources   Download

LGPL

The Requires

  • php >=5.3.0

 

tracking loop-tracker