. */ /** * Doctrine_Column * This class represents a database column * * @author Konsta Vesterinen * @package Doctrine * @subpackage Column * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @version $Revision$ * @link www.phpdoctrine.com * @since 1.0 */ class Doctrine_Column extends Doctrine_Access implements IteratorAggregate, Countable { /** * @var array $definition */ protected $_definition = array( 'type' => null, 'length' => 0, ); /** * @var array $definition */ public function __construct(array $definition = array()) { $this->_definition = $definition; } /** * @return array */ public function getDefinition() { return $this->_definition; } /** * contains * * @return boolean */ public function contains($name) { return isset($this->_definition[$name]); } /** * get * * @param string $name * @return mixed */ public function get($name) { if ( ! isset($this->_definition[$name])) { return null; } return $this->_definition[$name]; } /** * set * * @param string $name * @return mixed */ public function set($name, $value) { $this->_definition[$name] = $value; } /** * @param string $field * @return array */ public function getEnumValues() { if (isset($this->_definition['values'])) { return $this->_definition['values']; } else { return array(); } } /** * enumValue * * @param string $field * @param integer $index * @return mixed */ public function enumValue($index) { if ($index instanceof Doctrine_Null) { return $index; } return isset($this->_definition['values'][$index]) ? $this->_definition['values'][$index] : $index; } /** * enumIndex * * @param string $field * @param mixed $value * @return mixed */ public function enumIndex($field, $value) { $values = $this->getEnumValues($field); return array_search($value, $values); } /** * count * * @return integer */ public function count() { return count($this->_definition); } /** * getIterator * * @return ArrayIterator */ public function getIterator() { return new ArrayIterator($this->_definition); } }