null, 'propertyName' => null, 'propertyType' => ezcPersistentObjectProperty::PHP_TYPE_INT, 'generator' => null, 'visibility' => null, ); /** * Constructs a new PersistentObjectField * * @param string $columnName The name of the database field that stores the value. * @param string $propertyName The name of the class member * @param int $visibility See {@link $visibility} for possible values. * @param ezcPersistentGeneratorDefinition $generator Definition of the identifier generator * @param int $propertyType See {@link ezcPersistentObjectProperty} for possible values. */ public function __construct( $columnName = null, $propertyName = null, $visibility = null, ezcPersistentGeneratorDefinition $generator = null, $propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT ) { $this->columnName = $columnName; $this->propertyName = $propertyName; $this->visibility = $visibility; $this->generator = $generator; $this->propertyType = $propertyType; } /** * Property read access. * * @param string $propertyName Name of the property. * @return mixed Value of the property or null. * * @throws ezcBasePropertyNotFoundException * If the the desired property is not found. * @ignore */ public function __get( $propertyName ) { if ( $this->__isset( $propertyName ) ) { return $this->properties[$propertyName]; } throw new ezcBasePropertyNotFoundException( $propertyName ); } /** * Property write access. * * @param string $propertyName Name of the property. * @param mixed $propertyValue The value for the property. * * @throws ezcBasePropertyNotFoundException * If a the value for the property options is not an instance of * @throws ezcBaseValueException * If a the value for a property is out of range. * @ignore */ public function __set( $propertyName, $propertyValue ) { switch ( $propertyName ) { case 'columnName': case 'propertyName': if ( is_string( $propertyValue ) === false && is_null( $propertyValue ) === false ) { throw new ezcBaseValueException( $propertyName, $propertyValue, 'string or null' ); } break; case 'propertyType': case 'visibility': if ( is_int( $propertyValue ) === false && is_null( $propertyValue ) === false ) { throw new ezcBaseValueException( $propertyName, $propertyValue, 'int or null' ); } break; case 'generator': if ( ( is_object( $propertyValue ) === false || ( $propertyValue instanceof ezcPersistentGeneratorDefinition ) === false ) && is_null( $propertyValue ) === false ) { throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcPersistentGeneratorDefinition or null' ); } break; default: throw new ezcBasePropertyNotFoundException( $propertyName ); break; } $this->properties[$propertyName] = $propertyValue; } /** * Property isset access. * * @param string $propertyName Name of the property. * @return bool True is the property is set, otherwise false. * @ignore */ public function __isset( $propertyName ) { return array_key_exists( $propertyName, $this->properties ); } /** * Returns a new instance of this class with the data specified by $array. * * $array contains all the data members of this class in the form: * array('member_name'=>value). * * __set_state makes this class exportable with var_export. * var_export() generates code, that calls this method when it * is parsed with PHP. * * @param array(string=>mixed) $array * @return ezcPersistentObjectIdProperty */ public static function __set_state( array $array ) { return new ezcPersistentObjectIdProperty( $array['columnName'], $array['propertyName'], $array['visibility'], $array['generator'] ); } } ?>