<?php
class Goweb_Chart_Set {
    
    // ------------------------------------------------ //
    // PROPERTIES -------------------------- PROPERTIES //
    // ------------------------------------------------ //
    
    private $_set     = array();
    private $_options = array();
    private $_setElement = array();
    
    // ------------------------------------------------ //
    // METHODS -------------------------------- METHODS //
    // ------------------------------------------------ //
    public function __construct() {
        $this->_options = array('label', 'value', 'color', 'link', 'toolText',
                               'showLabel', 'showValue', 'alpha', 'isSliced');
    }
    
    public function add() {
        $setInput = '<set ';
        foreach ($this->_set as $key => $value) {
            $setInput .= $key . "='" . $value . "' ";
        }
        $setInput .= ' />';
        $this->_setElement[] = $setInput;
        
        $this->_clearOptions();
    }
    
    public function render() {
        $setInputs = "";
        foreach ($this->_setElement as $setElement) {
            $setInputs .= $setElement . "";
        }
        $this->_setElement = array();
        return $setInputs;
    }
    
    public function __set($key, $value) {
        if (in_array(trim($key), $this->_options)) {
            $this->_set[$key] = $value;
        }
    }
    
    private function _clearOptions() {
        $this->_set = array();
    }
    
}
?>
