lithium\data\DocumentSchema::_castType()
Casts a scalar (non-object/array) value to its corresponding database-native value or custom
value object based on a handler assigned to $field
's data type.
Parameters
-
mixed
$value
The value to be cast.
-
string
$field
The name of the field that
$value
is or will be stored in. If it is a nested field,$field
should be the full dot-separated path to the sub-object's field.
Returns
mixedReturns the result of $value
, modified by a matching handler data type
handler, if available.
Source
protected function _castType($value, $field) {
if ($this->is('null', $field) && ($value === null || $value === "")) {
return null;
}
if (!is_scalar($value)) {
return $value;
}
$type = $this->type($field);
return isset($this->_handlers[$type]) ? $this->_handlers[$type]($value) : $value;
}