Skip to content

Instantly share code, notes, and snippets.

@craiga
Last active October 9, 2015 05:18
Show Gist options
  • Save craiga/3444731 to your computer and use it in GitHub Desktop.
Save craiga/3444731 to your computer and use it in GitHub Desktop.
_logProgress
<?php
/**
* Log progress.
*
* Log progress with a message along the lines of "Processed 600 of 20,000 items (3%)."
* Makes use of {@link https://gist.github.com/1849563 _log}.
*
* @author Craig Anderson <[email protected]>
* @link https://gist.github.com/3444731
*/
protected function _logProgress($upto, $total, $pluralNoun = "items", $pastTenseVerb = "processed")
{
$this->_log("%s %s of %s %s (%d%%).",
ucfirst($pastTenseVerb),
number_format($upto),
number_format($total),
$pluralNoun,
($upto / $total) * 100
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment