HistogramTransform

The Contact Form DB HistogramTransform class.

Defined (1)

The class is defined in the following location(s).

/HistogramTransform.php  
  1. abstract class HistogramTransform implements CFDBTransform { 
  2.  
  3. /** 
  4. * @var string field holding the value 
  5. */ 
  6. var $valueField; 
  7.  
  8. /** 
  9. * @var string field to group by 
  10. */ 
  11. var $groupByField; 
  12.  
  13. /** 
  14. * @var array of name => value 
  15. */ 
  16. var $values = array(); 
  17.  
  18. function __construct($valueField, $groupByField) { 
  19. $this->valueField = $valueField; 
  20. $this->groupByField = $groupByField; 
  21.  
  22. // https://bugs.php.net/bug.php?id=43200 
  23. // abstract method also defined interface is an error in PHP 5.0.0 - 5.3.8 
  24. //abstract public function addEntry(&$entry); 
  25.  
  26. public function getTransformedData() { 
  27. $data = array(); 
  28. foreach ($this->values as $name => $value) { 
  29. if (empty($this->groupByField)) { 
  30. $data[] = array($this->valueField => $value); 
  31. } else { 
  32. $data[] = array($this->groupByField => $name, $this->valueField => $value); 
  33. return $data; 
  34.  
  35.