public function convertToType($type, $value)
{
switch (strtolower($type)) {
case 'integer':
case 'int':
$type = 'integer';
break;
case 'float':
case 'double':
case 'decimal':
$type = 'float';
break;
case 'boolean':
case 'bool':
$type = 'boolean';
break;
case 'string':
$type = 'string';
break;
default:
return $value;
}
settype($value, $type);
return $value;
}