original_string: public function set($data, $bean) {
  
  		// Add all properties to bean
  		foreach ( $this->properties as $property ) {
  
  			$value = false; // We need to clear possible previous $value
  
  			// Define property controller
  			$c = new $property['type'];
  
  			// New input for the property
  			if (
  				isset( $data[ $property['name'] ] )
  				|| 
  				( isset( $_FILES[ $property['name'] ] ) && $_FILES[ $property['name'] ]['size'] > 0 )
  				||
  				$property['autovalue'] == true
  			) {
  
  				// Check if specific set property type method exists
  				if ( method_exists( $c, 'set' ) ) {
  
  					$value = $c->set( $bean, $property, $data[ $property['name'] ] );
  
  				} else {
  
  					$value = $data[ $property['name'] ];
  
  				}
  
  				if ($value) {
  					$hasvalue = true;
  				} else {
  					$hasvalue = false;
  				}
  
  			// No new input for the property
  			} else {
  
  				// Check if property already has value for required validation
  				if ( isset( $property['required'] ) ) {
  
  					if ( method_exists( $c, 'read' ) && $c->read( $bean, $property ) ) {
  						$hasvalue = true;
  					} else if ( $bean->{ $property['name'] } ) {
  						$hasvalue = true;
  					} else {
  						$hasvalue = false;
  					}
  
  				}
  
  			}
  
  			// Check if property is required
  			if ( isset( $property['required'] ) ) {
  				if ( $property['required'] && !$hasvalue ) {
  					throw new \Exception('Validation error. '.$property['description'].' is required.');
  				}
  			}
  
  			// Results from methods that return boolean values are not stored.
  			// Many-to-many relations for example are stored in a seperate table.
  			if ( !is_bool($value) ) {
  
  				// Check if property value is unique
  				if ( isset( $property['unique'] ) ) {
  					$duplicate = \R::findOne( $this->type, $property['name'].' = :val ', [ ':val' => $value ] );
  					if ( $duplicate && $duplicate->id != $bean->id ) {
  						throw new \Exception('Validation error. '.$property['description'].' should be unique.');
  					}
  				}
  
  				$bean->{ $property['name'] } = $value;
  			}
  
  		}
  
  		$bean->modified = \R::isoDateTime();
  		\R::store($bean);
  
  		return $bean;
  
  	}
code: public function set($data, $bean) {
  
  		// Add all properties to bean
  		foreach ( $this->properties as $property ) {
  
  			$value = false; // We need to clear possible previous $value
  
  			// Define property controller
  			$c = new $property['type'];
  
  			// New input for the property
  			if (
  				isset( $data[ $property['name'] ] )
  				|| 
  				( isset( $_FILES[ $property['name'] ] ) && $_FILES[ $property['name'] ]['size'] > 0 )
  				||
  				$property['autovalue'] == true
  			) {
  
  				// Check if specific set property type method exists
  				if ( method_exists( $c, 'set' ) ) {
  
  					$value = $c->set( $bean, $property, $data[ $property['name'] ] );
  
  				} else {
  
  					$value = $data[ $property['name'] ];
  
  				}
  
  				if ($value) {
  					$hasvalue = true;
  				} else {
  					$hasvalue = false;
  				}
  
  			// No new input for the property
  			} else {
  
  				// Check if property already has value for required validation
  				if ( isset( $property['required'] ) ) {
  
  					if ( method_exists( $c, 'read' ) && $c->read( $bean, $property ) ) {
  						$hasvalue = true;
  					} else if ( $bean->{ $property['name'] } ) {
  						$hasvalue = true;
  					} else {
  						$hasvalue = false;
  					}
  
  				}
  
  			}
  
  			// Check if property is required
  			if ( isset( $property['required'] ) ) {
  				if ( $property['required'] && !$hasvalue ) {
  					throw new \Exception('Validation error. '.$property['description'].' is required.');
  				}
  			}
  
  			// Results from methods that return boolean values are not stored.
  			// Many-to-many relations for example are stored in a seperate table.
  			if ( !is_bool($value) ) {
  
  				// Check if property value is unique
  				if ( isset( $property['unique'] ) ) {
  					$duplicate = \R::findOne( $this->type, $property['name'].' = :val ', [ ':val' => $value ] );
  					if ( $duplicate && $duplicate->id != $bean->id ) {
  						throw new \Exception('Validation error. '.$property['description'].' should be unique.');
  					}
  				}
  
  				$bean->{ $property['name'] } = $value;
  			}
  
  		}
  
  		$bean->modified = \R::isoDateTime();
  		\R::store($bean);
  
  		return $bean;
  
  	}
code_tokens: public function set ( $ data , $ bean ) { // Add all properties to bean foreach ( $ this -> properties as $ property ) { $ value = false ; // We need to clear possible previous $value // Define property controller $ c = new $ property [ 'type' ] ; // New input for the property if ( isset ( $ data [ $ property [ 'name' ] ] ) || ( isset ( $ _FILES [ $ property [ 'name' ] ] ) && $ _FILES [ $ property [ 'name' ] ] [ 'size' ] > 0 ) || $ property [ 'autovalue' ] == true ) { // Check if specific set property type method exists if ( method_exists ( $ c , 'set' ) ) { $ value = $ c -> set ( $ bean , $ property , $ data [ $ property [ 'name' ] ] ) ; } else { $ value = $ data [ $ property [ 'name' ] ] ; } if ( $ value ) { $ hasvalue = true ; } else { $ hasvalue = false ; } // No new input for the property } else { // Check if property already has value for required validation if ( isset ( $ property [ 'required' ] ) ) { if ( method_exists ( $ c , 'read' ) && $ c -> read ( $ bean , $ property ) ) { $ hasvalue = true ; } else if ( $ bean -> { $ property [ 'name' ] } ) { $ hasvalue = true ; } else { $ hasvalue = false ; } } } // Check if property is required if ( isset ( $ property [ 'required' ] ) ) { if ( $ property [ 'required' ] && ! $ hasvalue ) { throw new \ Exception ( 'Validation error. ' . $ property [ 'description' ] . ' is required.' ) ; } } // Results from methods that return boolean values are not stored. // Many-to-many relations for example are stored in a seperate table. if ( ! is_bool ( $ value ) ) { // Check if property value is unique if ( isset ( $ property [ 'unique' ] ) ) { $ duplicate = \ R :: findOne ( $ this -> type , $ property [ 'name' ] . ' = :val ' , [ ':val' => $ value ] ) ; if ( $ duplicate && $ duplicate -> id != $ bean -> id ) { throw new \ Exception ( 'Validation error. ' . $ property [ 'description' ] . ' should be unique.' ) ; } } $ bean -> { $ property [ 'name' ] } = $ value ; } } $ bean -> modified = \ R :: isoDateTime ( ) ; \ R :: store ( $ bean ) ; return $ bean ; }
docstring: Set values for a bean. Used by Create and Update.
  Checks for each property if a "set" method exists for it's type.
  If so, it executes it.
  
  @param array	$data	The raw data, usually from the Slim $request->getParsedBody()
  @param bean	$bean
  
  @return bean	Bean with values based on $data.
docstring_tokens: Set values for a bean . Used by Create and Update . Checks for each property if a set method exists for it s type . If so it executes it .