<?php
class Progress {
  var $max = 0;
  var $lastpercent = 0;
  function __construct($max) {
    $this->max=$max;
    if ($this->max <= 0) {
      print "WARNING: Progress must be initialized with a value greater than zero. Current value: $max\n";
    }
  }
  function show($value) {
      $percent = round(100*($value / $this->max)-0.5);
      if ($percent > $this->lastpercent) {
          $this->lastpercent=$percent;
          if ($percent%10 == 0) {
              print $percent;
              if ($percent >= 100) {
                print "\n";
              }
          } else {
              print ".";
          }
      }
  }
}
