GetXmlTypeCode
@param Type $type
@return XmlTypeCode
16825
public static function GetXmlTypeCodeFromType( $type )
	{
		/**
		 * @var TypeCode
		 */
		switch ( $type->getTypeCode() )
		{
			case TypeCode::Boolean:
				return XmlTypeCode::Boolean;
			case TypeCode::Int16:
				return XmlTypeCode::Short;
			case TypeCode::Int32:
				return XmlTypeCode::Int;
			case TypeCode::Int64:
				return XmlTypeCode::Long;
			case TypeCode::UInt16:
				return XmlTypeCode::UnsignedShort;
			case TypeCode::UInt32:
				return XmlTypeCode::UnsignedInt;
			case TypeCode::UInt64:
				return XmlTypeCode::UnsignedLong;
			case TypeCode::SByte:
				return XmlTypeCode::Byte;
			case TypeCode::Byte:
				return XmlTypeCode::UnsignedByte;
			case TypeCode::Single:
				return XmlTypeCode::Float;
			case TypeCode::Decimal:
				return XmlTypeCode::Decimal;
			case TypeCode::Double:
				return XmlTypeCode::Double;
			case TypeCode::Char:
			case TypeCode::String:
				return XmlTypeCode::String;
			default:
				$typeName = $type->getTypeName();
				if ($typeName == DOMXPathNavigator::$CLASSNAME )
					return XmlTypeCode::Node;
				if ($typeName == UntypedAtomic::$CLASSNAME )
					return XmlTypeCode::UntypedAtomic;
				if ($typeName == Integer::$CLASSNAME )
					return XmlTypeCode::Integer;
				if ($typeName == DateTimeValue::$CLASSNAME )
					return XmlTypeCode::DateTime;
				if ($typeName == DateValue::$CLASSNAME )
					return XmlTypeCode::Date;
				if ($typeName == TimeValue::$CLASSNAME )
					return XmlTypeCode::Time;
				if ($typeName == DurationValue::$CLASSNAME )
					return XmlTypeCode::Duration;
				if ($typeName == YearMonthDurationValue::$CLASSNAME)
					return XmlTypeCode::YearMonthDuration;
				if ($typeName == DayTimeDurationValue::$CLASSNAME )
					return XmlTypeCode::DayTimeDuration;
				if ($typeName == GYearMonthValue::$CLASSNAME )
					return XmlTypeCode::GYearMonth;
				if ($typeName == GYearValue::$CLASSNAME )
					return XmlTypeCode::GYear;
				if ($typeName == GDayValue::$CLASSNAME )
					return XmlTypeCode::GDay;
				if ($typeName == GMonthValue::$CLASSNAME )
					return XmlTypeCode::GMonth;
				if ($typeName == GMonthDayValue::$CLASSNAME )
					return XmlTypeCode::GMonthDay;
				if ($typeName == QNameValue::$CLASSNAME )
					return XmlTypeCode::QName;
				if ($typeName == AnyUriValue::$CLASSNAME )
					return XmlTypeCode::AnyUri;
				if ($typeName == HexBinaryValue::$CLASSNAME )
					return XmlTypeCode::HexBinary;
				if ($typeName == Base64BinaryValue::$CLASSNAME )
					return XmlTypeCode::Base64Binary;
				if ($typeName == IDREFSValue::$CLASSNAME )
					return XmlTypeCode::Idref;
				if ($typeName == ENTITIESValue::$CLASSNAME )
					return XmlTypeCode::Entity;
				if ($typeName == NMTOKENSValue::$CLASSNAME )
					return XmlTypeCode::NmToken;
				return XmlTypeCode::Item;
		}
	}
293768
protected function getDoctrineColumnType($type)
	{
		$type = strtolower($type);

		switch ($type) {
			case 'biginteger':
				$type = 'bigint';
				break;
			case 'smallinteger':
				$type = 'smallint';
				break;
			case 'mediumtext':
			case 'longtext':
				$type = 'text';
				break;
		}

		return Type::getType($type);
	}
655433
public function to($type)
    {
        switch ($type) {
            case 'ini':
                $this->string = Ini::encode($this->data);
                break;

            case 'json':
                $this->string = Json::encode($this->data, $this->prettyOutput);
                break;

            case 'php':
                $this->string = Php::encode($this->data);
                break;

            case 'xml':
                $this->string = Xml::encode($this->data, $this->prettyOutput);
                break;

            case 'yml':
            case 'yaml':
                $this->string = Yaml::encode($this->data);
                break;
            
            default:
                throw new \Exception("Format not supported: " . $type);
        }

        return $this->string;
    }
779704
public function GetPHPStandardType(
        \Peg\Lib\Definitions\Element\VariableType $type
    )
    {
        $standard_type = $this->GetStandardType($type);
        $php_type = "";

        switch($standard_type)
        {
            case StandardType::BOOLEAN:
                $php_type .= "bool";
                break;

            case StandardType::INTEGER:
                $php_type .= "int";
                break;

            case StandardType::REAL:
                $php_type .= "float";
                break;

            case StandardType::CHARACTER:
                $php_type .= "string";
                break;

            case StandardType::VOID:
                $php_type .= "void";
                break;

            case StandardType::OBJECT:
                $php_type .= $type->type;
                break;
            
            case StandardType::CLASS_ENUM:
                $php_type .= $type->type . "| int";
                break;
            
            case StandardType::ENUM:
                $php_type .= "int";
                break;
            
            case StandardType::UNKNOWN:
                $php_type .= "unknown";
                break;
        }
        
        return $php_type;
    }
1266703
public function getXMLDBTypeName($type) {

        $result = "";

        switch (strtolower($type)) {
            case XMLDB_TYPE_INTEGER:
                $result = 'int';
                break;
            case XMLDB_TYPE_NUMBER:
                $result = 'number';
                break;
            case XMLDB_TYPE_FLOAT:
                $result = 'float';
                break;
            case XMLDB_TYPE_CHAR:
                $result = 'char';
                break;
            case XMLDB_TYPE_TEXT:
                $result = 'text';
                break;
            case XMLDB_TYPE_BINARY:
                $result = 'binary';
                break;
            case XMLDB_TYPE_DATETIME:
                $result = 'datetime';
                break;
        }
        // Return the normalized name
        return $result;
    }
1220385
protected static function getNodes(DOMDocument $dom, $type)
	{
		$nodes  = [];
		$prefix = ($type === 'attribute') ? '@' : '';
		$xpath  = new DOMXPath($dom);

		// Get natural nodes
		foreach ($xpath->query('//' . $prefix . '*') as $node)
		{
			$nodes[] = [$node, $node->nodeName];
		}

		// Get XSL-generated nodes
		foreach ($xpath->query('//xsl:' . $type) as $node)
		{
			$nodes[] = [$node, $node->getAttribute('name')];
		}

		// Get xsl:copy-of nodes
		foreach ($xpath->query('//xsl:copy-of') as $node)
		{
			if (preg_match('/^' . $prefix . '(\\w+)$/', $node->getAttribute('select'), $m))
			{
				$nodes[] = [$node, $m[1]];
			}
		}

		return $nodes;
	}
956189
protected function extractGeneric($type)
    {
        if (empty($type)) {
            return null;
        }

        $generic = null;

        if (substr($type, -2) === '[]') {
            $generic = substr($type, 0, -2);
        }
        elseif (strtolower(substr($type, 0, 6)) === 'array<' && substr($type, -1) === '>') {
            $generic = substr($type, 6, -1);
        }

        return $generic;
    }
523190
public static function getTypeForCode( $typeCode )
	{
		return isset( XmlTypeCode::$codeToTypeMap[ $typeCode ] )
			? XmlTypeCode::$codeToTypeMap[ $typeCode ]
			: false;
	}
340882
protected static function toXpath($code, $type='html', $encoding='UTF-8') {
		$doc = new \DOMDocument();
		if ($type == 'xml')
			@$doc->loadXML('<?xml encoding="'.$encoding.'">' . $code);
		else
			@$doc->loadHTML('<?xml encoding="'.$encoding.'">' . $code);

		foreach($doc->childNodes as $item) {
			if($item->nodeType == XML_PI_NODE)
				$doc->removeChild($item); #remove encoding node
		}

		return new \DOMXPath($doc);
	}
532824
public function getLabels( $type = 0, $xml = TRUE )
	{
 		$content = preg_replace( '/<%\??--.*--%>/sU', '', $this->template );	
		switch( $type )
		{
			case 2:
				preg_match_all( '/<%(\?.*)%>/U', $content, $tags );
				break;
			case 1:
				preg_match_all( '/<%([^-?].*)%>/U', $content, $tags );
				break;
			default:
				preg_match_all( '/<%([^-].*)%>/U', $content, $tags );
		}
		return $xml ? $tags[0] : $tags[1];
	}
1122222
private static function getClass($type)
    {
        if (!\array_key_exists($type, self::$types)) {
            throw new \RuntimeException('invalid type');
        }

        return self::$types[$type];
    }
744133
public function getEncoderForType(string $type): IEncoder
    {
        $normalizedType = self::normalizeType($type);

        if (isset($this->encodersByType[$normalizedType])) {
            return $this->encodersByType[$normalizedType];
        }

        if (class_exists($type)) {
            if ($this->defaultObjectEncoder === null) {
                throw new OutOfBoundsException('No default object encoder is registered');
            }

            return $this->defaultObjectEncoder;
        }

        if ($this->defaultScalarEncoder === null) {
            throw new OutOfBoundsException('No default scalar encoder is registered');
        }

        return $this->defaultScalarEncoder;
    }
288394
public function findElementtypeByType($type)
    {
        $elementtypes = [];
        foreach ($this->elementtypeManager->findAll() as $elementtype) {
            if ($elementtype->getType() === $type) {
                $elementtypes[] = $elementtype;
            }
        }

        return $elementtypes;
    }
858711
public static function getCardType($type)
    {
        if (isset(self::$cardTypes[$type])) {
            return self::$cardTypes[$type];
        }
        return $type;
    }
250460
private function getTypeSuffix($type)
    {
        self::$TYP_MAPPING = array_merge(self::$TYP_COMPLEX_MAPPING, self::$TYP_SIMPLE_MAPPING);

        if ($type == '') {
            return '';
        }

        if (!isset(self::$TYP_MAPPING[$this->type])) {
            return '';
        }

        return self::$TYP_MAPPING[$this->type];
    }
432075
public static function getCodeName( $typeCode )
	{
		// Maybe this should be: XmlTypeCode::$codeToTypeMap[ $typeCode ];
		$oClass = new \ReflectionClass( __CLASS__ );
		foreach ( $oClass->getConstants() as $key => $value )
		{
			if ( $value == $typeCode ) return $key;
		}

		return false;
	}
325345
protected function createContent($type)
    {
        if ($type == 'json') {
            $this->headers['content_type'] = 'application/json; charset=UTF-8';

            return json_encode(['url' => $this->ch, 'status' => 'ok']);
        } elseif ($type == 'xml') {
            $this->headers['content_type'] = 'text/xml; charset=UTF-8';

            return '<?xml version="1.0" encoding="UTF-8"?><result><url>'.$this->ch.'</url><status>ok</status></result>';
        }

        return 'ok';
    }