. */ require_once('CFDBTransform.php'); abstract class HistogramTransform implements CFDBTransform { /** * @var string field holding the value */ var $valueField; /** * @var string field to group by */ var $groupByField; /** * @var array of name => value */ var $values = array(); function __construct($valueField, $groupByField) { $this->valueField = $valueField; $this->groupByField = $groupByField; } // https://bugs.php.net/bug.php?id=43200 // abstract method also defined interface is an error in PHP 5.0.0 - 5.3.8 //abstract public function addEntry(&$entry); public function getTransformedData() { $data = array(); foreach ($this->values as $name => $value) { if (empty($this->groupByField)) { $data[] = array($this->valueField => $value); } else { $data[] = array($this->groupByField => $name, $this->valueField => $value); } } return $data; } }