original_string: public static function typecast($column, $value, $settings, $event_type	= 'before')
  	{
  		 // only on before_save, check if null is allowed
  		if ($value === null)
  		{
  			 // only on before_save
  			if ($event_type == 'before')
  			{
  				if (array_key_exists('null', $settings) and $settings['null'] === false)
  				{
  					// if a default is defined, return that instead
  					if (array_key_exists('default', $settings))
  					{
  						return $settings['default'];
  					}
  
  					throw new InvalidContentType('The property "'.$column.'" cannot be NULL.');
  				}
  			}
  			return $value;
  		}
  
  		// no datatype given
  		if (empty($settings['data_type']))
  		{
  			return $value;
  		}
  
  		// get the data type for this column
  		$data_type = $settings['data_type'];
  
  		// is this a base data type?
  		if ( ! isset(static::$type_methods[$data_type]))
  		{
  			// no, can we map it to one?
  			if (isset(static::$type_mappings[$data_type]))
  			{
  				// yes, so swap it for a base data type
  				$data_type = static::$type_mappings[$data_type];
  			}
  			else
  			{
  				// can't be mapped, check the regexes
  				foreach (static::$regex_methods as $match => $methods)
  				{
  					// fetch the method
  					$method = ! empty($methods[$event_type]) ? $methods[$event_type] : false;
  
  					if ($method)
  					{
  						if (preg_match_all($match, $data_type, $matches) > 0)
  						{
  							$value = call_user_func($method, $value, $settings, $matches);
  						}
  					}
  				}
  				return $value;
  			}
  		}
  
  		// fetch the method
  		$method = ! empty(static::$type_methods[$data_type][$event_type]) ? static::$type_methods[$data_type][$event_type] : false;
  
  		// if one was found, call it
  		if ($method)
  		{
  			$value = call_user_func($method, $value, $settings);
  		}
  
  		return $value;
  	}
code: public static function typecast($column, $value, $settings, $event_type	= 'before')
  	{
  		 // only on before_save, check if null is allowed
  		if ($value === null)
  		{
  			 // only on before_save
  			if ($event_type == 'before')
  			{
  				if (array_key_exists('null', $settings) and $settings['null'] === false)
  				{
  					// if a default is defined, return that instead
  					if (array_key_exists('default', $settings))
  					{
  						return $settings['default'];
  					}
  
  					throw new InvalidContentType('The property "'.$column.'" cannot be NULL.');
  				}
  			}
  			return $value;
  		}
  
  		// no datatype given
  		if (empty($settings['data_type']))
  		{
  			return $value;
  		}
  
  		// get the data type for this column
  		$data_type = $settings['data_type'];
  
  		// is this a base data type?
  		if ( ! isset(static::$type_methods[$data_type]))
  		{
  			// no, can we map it to one?
  			if (isset(static::$type_mappings[$data_type]))
  			{
  				// yes, so swap it for a base data type
  				$data_type = static::$type_mappings[$data_type];
  			}
  			else
  			{
  				// can't be mapped, check the regexes
  				foreach (static::$regex_methods as $match => $methods)
  				{
  					// fetch the method
  					$method = ! empty($methods[$event_type]) ? $methods[$event_type] : false;
  
  					if ($method)
  					{
  						if (preg_match_all($match, $data_type, $matches) > 0)
  						{
  							$value = call_user_func($method, $value, $settings, $matches);
  						}
  					}
  				}
  				return $value;
  			}
  		}
  
  		// fetch the method
  		$method = ! empty(static::$type_methods[$data_type][$event_type]) ? static::$type_methods[$data_type][$event_type] : false;
  
  		// if one was found, call it
  		if ($method)
  		{
  			$value = call_user_func($method, $value, $settings);
  		}
  
  		return $value;
  	}
code_tokens: public static function typecast ( $ column , $ value , $ settings , $ event_type = 'before' ) { // only on before_save, check if null is allowed if ( $ value === null ) { // only on before_save if ( $ event_type == 'before' ) { if ( array_key_exists ( 'null' , $ settings ) and $ settings [ 'null' ] === false ) { // if a default is defined, return that instead if ( array_key_exists ( 'default' , $ settings ) ) { return $ settings [ 'default' ] ; } throw new InvalidContentType ( 'The property "' . $ column . '" cannot be NULL.' ) ; } } return $ value ; } // no datatype given if ( empty ( $ settings [ 'data_type' ] ) ) { return $ value ; } // get the data type for this column $ data_type = $ settings [ 'data_type' ] ; // is this a base data type? if ( ! isset ( static :: $ type_methods [ $ data_type ] ) ) { // no, can we map it to one? if ( isset ( static :: $ type_mappings [ $ data_type ] ) ) { // yes, so swap it for a base data type $ data_type = static :: $ type_mappings [ $ data_type ] ; } else { // can't be mapped, check the regexes foreach ( static :: $ regex_methods as $ match => $ methods ) { // fetch the method $ method = ! empty ( $ methods [ $ event_type ] ) ? $ methods [ $ event_type ] : false ; if ( $ method ) { if ( preg_match_all ( $ match , $ data_type , $ matches ) > 0 ) { $ value = call_user_func ( $ method , $ value , $ settings , $ matches ) ; } } } return $ value ; } } // fetch the method $ method = ! empty ( static :: $ type_methods [ $ data_type ] [ $ event_type ] ) ? static :: $ type_methods [ $ data_type ] [ $ event_type ] : false ; // if one was found, call it if ( $ method ) { $ value = call_user_func ( $ method , $ value , $ settings ) ; } return $ value ; }
docstring: Typecast a single column value based on the model properties for that column
  
  @param  string  $column	name of the column
  @param  string  $value	value
  @param  string  $settings	column settings from the model
  
  @throws  InvalidContentType
  
  @return  mixed
docstring_tokens: Typecast a single column value based on the model properties for that column