private function castValue($value)
    {
        foreach ([
            // Integers
            '/^-?\d+$/' => function ($value) {
                return (int) $value;
            },
            // Floats
            '/^-?\d+\.\d+$/' => function ($value) {
                return (float) $value;
            },
            // Booleans
            '/^(?:true|false)$/' => function ($value) {
                return filter_var($value, \FILTER_VALIDATE_BOOLEAN);
            },
        ] as $format => $castFunction) {
            if (preg_match($format, $value)) {
                return $castFunction($value);
            }
        }

        return $value;
    }