protected function castValueWithCommonType($value, string $commonType)
    {
        // these are sorted by the most common data types to avoid extra comparisons
        if (null === $value) {
            return null;
        }
        if (CommonTypes::TTEXT === $commonType) {
            return strval($value);
        }
        if (CommonTypes::TINT === $commonType) {
            return intval($value);
        }
        if (CommonTypes::TNUMBER === $commonType) {
            return floatval($value);
        }
        if (CommonTypes::TBOOL === $commonType) {
            return (bool) $value;
        }
        if (in_array($commonType, [CommonTypes::TDATE, CommonTypes::TTIME, CommonTypes::TDATETIME], true)) {
            return strtotime($value);
        }
        return strval($value);
    }
protected function castValueWithCommonType($value, string $commonType)
    {
        // these are sorted by the most common data types to avoid extra comparisons
        if (null === $value) {
            return null;
        }
        if (CommonTypes::TTEXT === $commonType) {
            return strval($value);
        }
        if (CommonTypes::TINT === $commonType) {
            return intval($value);
        }
        if (CommonTypes::TNUMBER === $commonType) {
            return floatval($value);
        }
        if (CommonTypes::TBOOL === $commonType) {
            return (bool) $value;
        }
        if (in_array($commonType, [CommonTypes::TDATE, CommonTypes::TTIME, CommonTypes::TDATETIME], true)) {
            return strtotime($value);
        }
        return strval($value);
    }
protected function castValueWithCommonType ( $ value , string $ commonType ) { // these are sorted by the most common data types to avoid extra comparisons if ( null === $ value ) { return null ; } if ( CommonTypes :: TTEXT === $ commonType ) { return strval ( $ value ) ; } if ( CommonTypes :: TINT === $ commonType ) { return intval ( $ value ) ; } if ( CommonTypes :: TNUMBER === $ commonType ) { return floatval ( $ value ) ; } if ( CommonTypes :: TBOOL === $ commonType ) { return ( bool ) $ value ; } if ( in_array ( $ commonType , [ CommonTypes :: TDATE , CommonTypes :: TTIME , CommonTypes :: TDATETIME ] , true ) ) { return strtotime ( $ value ) ; } return strval ( $ value ) ; }
Cast a generic value from the source to a typed value, if null return null

@param mixed $value
@param string $commonType
@return mixed
Cast a generic value from the source to a typed value if null return null