From 56d36fdd34e79ba1870f2d49c5dbd4ee3653cfbd Mon Sep 17 00:00:00 2001 From: rojaro <> Date: Sun, 1 Nov 2009 21:32:45 +0000 Subject: TEnumerable can now be iterated as suggested by FragMaster B --- framework/TComponent.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'framework/TComponent.php') diff --git a/framework/TComponent.php b/framework/TComponent.php index 2fc0ebff..647653dd 100644 --- a/framework/TComponent.php +++ b/framework/TComponent.php @@ -608,8 +608,34 @@ class TComponent * @package System * @since 3.0 */ -class TEnumerable +class TEnumerable implements Iterator { + private $_enums = array(); + + public function __construct() { + $reflection = new ReflectionClass($this); + $this->_enums = $reflection->getConstants(); + } + + public function current() { + return current($this->_enums); + } + + public function key() { + return key($this->_enums); + } + + public function next() { + return next($this->_enums); + } + + public function rewind() { + reset($this->_enums); + } + + public function valid() { + return $this->current() !== false; + } } /** -- cgit v1.2.3