src/mako/database/midgard/ORM.php
protected function cast(string $name, $value)
	{
		if(isset($this->cast[$name]) && $value !== null)
		{
			switch($this->cast[$name])
			{
				case 'int':
					return (int) $value;
				case 'float':
					return (float) $value;
				case 'bool':
					return $value === 'f' ? false : (bool) $value;
				case 'date':
					return ($value instanceof DateTimeInterface) ? $value : Time::createFromFormat($this->getDateFormat(), $value);
				case 'string':
					return (string) $value;
				default:
					throw new RuntimeException(vsprintf('Unsupported type [ %s ].', [$this->cast[$name]]));
			}
		}

		return $value;
	}
protected function cast(string $name, $value)
	{
		if(isset($this->cast[$name]) && $value !== null)
		{
			switch($this->cast[$name])
			{
				case 'int':
					return (int) $value;
				case 'float':
					return (float) $value;
				case 'bool':
					return $value === 'f' ? false : (bool) $value;
				case 'date':
					return ($value instanceof DateTimeInterface) ? $value : Time::createFromFormat($this->getDateFormat(), $value);
				case 'string':
					return (string) $value;
				default:
					throw new RuntimeException(vsprintf('Unsupported type [ %s ].', [$this->cast[$name]]));
			}
		}

		return $value;
	}
protected function cast ( string $ name , $ value ) { if ( isset ( $ this -> cast [ $ name ] ) && $ value !== null ) { switch ( $ this -> cast [ $ name ] ) { case 'int' : return ( int ) $ value ; case 'float' : return ( float ) $ value ; case 'bool' : return $ value === 'f' ? false : ( bool ) $ value ; case 'date' : return ( $ value instanceof DateTimeInterface ) ? $ value : Time :: createFromFormat ( $ this -> getDateFormat ( ) , $ value ) ; case 'string' : return ( string ) $ value ; default : throw new RuntimeException ( vsprintf ( 'Unsupported type [ %s ].' , [ $ this -> cast [ $ name ] ] ) ) ; } } return $ value ; }
Cast value to the appropriate type.

@param  string            $name  Column name
@param  mixed             $value Column value
@throws \RuntimeException
@return mixed
Cast value to the appropriate type .