string) private $value; // proper value of the EnumType sub class instance protected function initInstance($init_type_name, $init_defd_vals, $init_value) { $this->type_name = $init_type_name; $this->defd_vals = $init_defd_vals; if ($init_value === null) { //default value requested $this->value = 1; } elseif (is_string($init_value) && ($vkey = array_search($init_value, $this->defd_vals)) !== false) { $this->value = $vkey; } elseif (array_key_exists ($init_value, $this->defd_vals)) { $this->value = $init_value; } else { throw new Exception("Invalid $this->type_name creation: $init_value"); } } public function getValue() { if (isset($this->defd_vals[$this->value])) { return $this->value; } else { throw new Exception("Invalid $this->type_name value (gotten): $this->value"); } } public function __toString() { if (isset($this->defd_vals[$this->value])) { return $this->defd_vals[$this->value]; } else { throw new Exception("Invalid $this->type_name value: $this->value"); } } public function compValue($comp_tag, $str_repr) { if (!(is_string($str_repr) && ($comp_val = array_search($str_repr, $this->defd_vals)) !== false)) throw new Exception("Invalid $this->type_name in filter comparison: $str_repr"); switch ($comp_tag) { case FilterTag::FC_EQUAL: return ($this->value == $comp_val); case FilterTag::FC_LESS: return ($this->value < $comp_val); case FilterTag::FC_GREATER: return ($this->value > $comp_val); } } public function equals(EnumType $e) { return ($this->value == $e->value); } }