public function resolveType($type)
    {
        if (is_numeric($type)) {
            return (int) $type;
        }

        $type = strtoupper($type);

        static $types = [
            'DOUBLE' => 1, 'STRING' => 2, 'OBJECT' => 3, 'ARRAY' => 4,
            'BINARY' => 5, 'ID' => 8, 'BOOL' => 8, 'BOOLEAN' => 8,
            'DATE' => 9, 'NULL' => 10, 'REGEX' => 11, 'JAVASCRIPT' => 13,
            'CODE' => 13, 'SYMBOL' => 14, 'JAVASCRIPT_SCOPE' => 15,
            'CODE_SCOPE' => 15, 'INT32' => 16, 'TS' => 17, 'TIMESTAMP' => 17,
            'INT64' => 18, 'MIN' => -1, 'MAX' => 127,
        ];

        if (! isset($types[$type])) {
            throw new \InvalidArgumentException('Type "'.$type.'" could not be resolved');
        }

        return $types[$type];
    }