protected function _castToExpression($value, $type)
    {
        if (empty($type)) {
            return $value;
        }

        $baseType = str_replace('[]', '', $type);
        $converter = Type::build($baseType);

        if (!$converter instanceof ExpressionTypeInterface) {
            return $value;
        }

        $multi = $type !== $baseType;

        if ($multi) {
            return array_map([$converter, 'toExpression'], $value);
        }

        return $converter->toExpression($value);
    }
protected function _castToExpression($value, $type)
    {
        if (empty($type)) {
            return $value;
        }

        $baseType = str_replace('[]', '', $type);
        $converter = Type::build($baseType);

        if (!$converter instanceof ExpressionTypeInterface) {
            return $value;
        }

        $multi = $type !== $baseType;

        if ($multi) {
            return array_map([$converter, 'toExpression'], $value);
        }

        return $converter->toExpression($value);
    }
protected function _castToExpression ( $ value , $ type ) { if ( empty ( $ type ) ) { return $ value ; } $ baseType = str_replace ( '[]' , '' , $ type ) ; $ converter = Type :: build ( $ baseType ) ; if ( ! $ converter instanceof ExpressionTypeInterface ) { return $ value ; } $ multi = $ type !== $ baseType ; if ( $ multi ) { return array_map ( [ $ converter , 'toExpression' ] , $ value ) ; } return $ converter -> toExpression ( $ value ) ; }
Conditionally converts the passed value to an ExpressionInterface object
if the type class implements the ExpressionTypeInterface. Otherwise,
returns the value unmodified.

@param mixed $value The value to converto to ExpressionInterface
@param string $type The type name
@return mixed
Conditionally converts the passed value to an ExpressionInterface object if the type class implements the ExpressionTypeInterface . Otherwise returns the value unmodified .