diff options
author | Fabio Bas <ctrlaltca@gmail.com> | 2015-01-20 23:53:59 +0100 |
---|---|---|
committer | Fabio Bas <ctrlaltca@gmail.com> | 2015-01-20 23:53:59 +0100 |
commit | bbda6a710849a46de98937e85e96ea06abe333fd (patch) | |
tree | 8325563cd0e406f1f6347dc8ad29560240d16430 /framework/TEnumerable.php | |
parent | ca22da21b0cedab985e698f4dedf3ac1158a1487 (diff) |
Once class per file: framework/*.php; removed pradolite
Diffstat (limited to 'framework/TEnumerable.php')
-rw-r--r-- | framework/TEnumerable.php | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/framework/TEnumerable.php b/framework/TEnumerable.php new file mode 100644 index 00000000..8dd42857 --- /dev/null +++ b/framework/TEnumerable.php @@ -0,0 +1,66 @@ +<?php +/** + * TComponent, TPropertyValue classes + * + * @author Qiang Xue <qiang.xue@gmail.com> + * + * Global Events, intra-object events, Class behaviors, expanded behaviors + * @author Brad Anderson <javalizard@mac.com> + * + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System + */ + + +/** + * TEnumerable class. + * TEnumerable is the base class for all enumerable types. + * To define an enumerable type, extend TEnumberable and define string constants. + * Each constant represents an enumerable value. + * The constant name must be the same as the constant value. + * For example, + * <code> + * class TTextAlign extends TEnumerable + * { + * const Left='Left'; + * const Right='Right'; + * } + * </code> + * Then, one can use the enumerable values such as TTextAlign::Left and + * TTextAlign::Right. + * + * @author Qiang Xue <qiang.xue@gmail.com> + * @package System + * @since 3.0 + */ +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; + } +}
\ No newline at end of file |