<?php

class LogBuffer
{
  public $buffer = array();
  
  public function log($item)
  {
    $this->buffer[] = DateTimeEx::nows()." - ".$item;
  }
  
  public function __toString()
  {
    $text = "";
    foreach($this->buffer as $timestamp => $item)
      $text .= $item.PHP_EOL;
    return $text;
  }

  public function count()
  {
    return count($this->buffer);
  }
  public function isEmpty()
  {
    return $this->count() <= 0;
  }
}
