Returns the constant representation (internal) of a given type.

@param int $type
The type as an integer

@return string
The string representation
6533
public static function typeToString($type)
    {
        switch ($type) {
            case self::EOF_TYPE:
                return 'EOF';
            case self::BANG_TYPE:
                return '!';
            case self::DOLLAR_TYPE:
                return '$';
            case self::PAREN_L_TYPE:
                return '(';
            case self::PAREN_R_TYPE:
                return ')';
            case self::SPREAD_TYPE:
                return '...';
            case self::COLON_TYPE:
                return ':';
            case self::EQUALS_TYPE:
                return '=';
            case self::AT_TYPE:
                return '@';
            case self::BRACKET_L_TYPE:
                return '[';
            case self::BRACKET_R_TYPE:
                return ']';
            case self::BRACE_L_TYPE:
                return '{';
            case self::PIPE_TYPE:
                return '|';
            case self::BRACE_R_TYPE:
                return '}';
            case self::NAME_TYPE:
                return 'Name';
            case self::VARIABLE_TYPE:
                return 'Variable';
            case self::INT_TYPE:
                return 'Int';
            case self::FLOAT_TYPE:
                return 'Float';
            case self::STRING_TYPE:
                return 'String';
            default:
                throw new \LogicException(sprintf('Token of type "%s" does not exist.', $type));
        }
    }
615225
public function getValueByType($type)
    {
        $type = strtoupper($type);

        switch ($type) {
            case static::EAN:
                return $this->asEan();

            case static::ISBN10:
                return $this->asIsbn10();

            case static::ISBN13:
                return $this->asIsbn13();

            case static::UPC:
                return $this->asUpc();

            default:
                throw new Exception("Type {$type} not supported");
        }
    }
664522
public function getType(string $type): Type
    {
        if (isset($this->types[$type])) {
            return $this->types[$type];
        }

        $instance = $this->createType($type);
        $this->addType($instance);
        $this->types[$type] = $instance;

        return $instance;
    }
682601
public function resolve(string $type) : string
    {
        $pos = strpos($type, '\\');

        if ($pos === 0) {
            return substr($type, 1); // Already fully qualified.
        }

        if ($pos === false) {
            $first = $type;
            $next = '';
        } else {
            $first = substr($type, 0, $pos);
            $next = substr($type, $pos);
        }

        $first = strtolower($first);

        if (isset($this->aliases[$first])) {
            return $this->aliases[$first] . $next;
        }

        return $this->namespace . '\\' . $type;
    }
550915
public function getString($type = self::RFC_4314)
    {
        $acl = strval($this);

        if ($type == self::RFC_2086) {
            foreach ($this->_virtual as $key => $val) {
                $acl = str_replace($val, '', $acl, $count);
                if ($count) {
                    $acl .= $key;
                }
            }
        }

        return $acl;
    }
91273
public static function getTypeName($type)
    {
        return isset(self::$names[$type])
            ? self::$names[$type]
            : null;
    }
653747
static public function getStorableType( $type )
    {
        switch ( $type )
        {
            case 'google':      return self::TYPE_GOOGLE;
            case 'facebook':    return self::TYPE_FACEBOOK;
            case 'yahoo':       return self::TYPE_YAHOO;
            case 'twitter':     return self::TYPE_TWITTER;
        }
    }
669452
protected function getTypeName()
    {
        $result = $this->type;
        foreach (get_defined_constants() as $name => $value) {
            if (substr($name, 0, 2) === 'T_' && $value === $this->type) {
                $result = $name;
                break;
            }
        }

        return $result;
    }
252984
public static function getName(int $type): string
    {
        if (!self::isValid($type)) {
            throw new \InvalidArgumentException(sprintf('The integer "%d" does not correspond to a valid type', $type));
        }

        return self::$names[$type];
    }
371092
public static function normalizeType(string $type): string
    {
        switch ($type) {
            case self::DATA_TYPE_INT:
            case self::DATA_TYPE_BIGINT:
            case self::DATA_TYPE_TINYINT:
            case self::DATA_TYPE_SMALLINT:
            case self::DATA_TYPE_MEDIUMINT:
            case self::DATA_TYPE_INTEGER:
            case self::DATA_TYPE_SERIAL:
            case self::DATA_TYPE_BIGSERIAL:
                return 'int';
            case self::DATA_TYPE_FLOAT:
            case self::DATA_TYPE_DECIMAL:
            case self::DATA_TYPE_DOUBLE:
            case self::DATA_TYPE_DOUBLEP:
            case self::DATA_TYPE_REAL:
            case self::DATA_TYPE_NUMERIC:
                return 'float';
            case self::DATA_TYPE_BOOLEAN:
                return 'bool';
            case self::DATA_TYPE_BIT:
                return 'bit';
        }

        // all others
        return 'string';
    }
1134597
public function getName($type)
    {
        $ref = new \ReflectionClass($this);
        foreach ($ref->getConstants() as $name => $value) {
            if ($value === $type) {
                return $name;
            }
        }

        throw new \InvalidArgumentException(sprintf('There is no token with value %s.', json_encode($type)));
    }
293621
public function format($type = null)
    {
        $type = $type ?: Constants::DEFAULT_FORMAT;

        if (!is_null($value = $this->config->get("format.{$type}"))) {
            return $this->replaceVariables($value);
        }
    }
25224
public function getEmptyValue(string $type)
    {
        $type = strtolower($type);
        $typeToValue = [
            'date' => '1970-01-01',
            'datetime' => '1970-01-01 00:00:00',
            'time' => '00:00:00',
            'smallint' => 0,
            'integer' => 0,
            'bigint' => 0,
            'float' => 0,
            'decimal' => 0,
        ];

        // Value is simply an empty string
        if (!array_key_exists($type, $typeToValue)) {
            return '';
        }

        return $typeToValue[$type];
    }
683101
private function getTypeName($type)
    {
        switch ($this->getTypePrimitive($type)) {
            case (self::WKB_TYPE_POINT):
                $typeName = self::TYPE_POINT;
                break;
            case (self::WKB_TYPE_LINESTRING):
                $typeName = self::TYPE_LINESTRING;
                break;
            case (self::WKB_TYPE_POLYGON):
                $typeName = self::TYPE_POLYGON;
                break;
            case (self::WKB_TYPE_MULTIPOINT):
                $typeName = self::TYPE_MULTIPOINT;
                break;
            case (self::WKB_TYPE_MULTILINESTRING):
                $typeName = self::TYPE_MULTILINESTRING;
                break;
            case (self::WKB_TYPE_MULTIPOLYGON):
                $typeName = self::TYPE_MULTIPOLYGON;
                break;
            case (self::WKB_TYPE_GEOMETRYCOLLECTION):
                $typeName = self::TYPE_GEOMETRYCOLLECTION;
                break;
            case (self::WKB_TYPE_CIRCULARSTRING):
                $typeName = self::TYPE_CIRCULARSTRING;
                break;
            case (self::WKB_TYPE_COMPOUNDCURVE):
                $typeName = self::TYPE_COMPOUNDCURVE;
                break;
            case (self::WKB_TYPE_CURVEPOLYGON):
                $typeName = self::TYPE_CURVEPOLYGON;
                break;
            case (self::WKB_TYPE_MULTICURVE):
                $typeName = self::TYPE_MULTICURVE;
                break;
            case (self::WKB_TYPE_MULTISURFACE):
                $typeName = self::TYPE_MULTISURFACE;
                break;
            case (self::WKB_TYPE_POLYHEDRALSURFACE):
                $typeName = self::TYPE_POLYHEDRALSURFACE;
                break;
            default:
                throw new UnexpectedValueException('Unsupported WKB type "' . $this->type . '"');
        }

        return strtoupper($typeName);
    }
43111
public static function getName($type)
    {
        if (array_key_exists($type, self::$formatName)) {
            return self::$formatName[$type];
        } else {
            return Pel::fmt('Unknown format: 0x%X', $type);
        }
    }
694060
protected function _getMethodNameForType($type = null) {
		$result = '_getValueForString';
		if (empty($type)) {
			return $result;
		}

		$type = mb_strtolower($type);
		$methodName = '_getValueFor' . Inflector::camelize($type);
		if (method_exists($this, $methodName)) {
			$result = $methodName;
		}

		return $result;
	}
350455
public function r($type) {
    switch ($type) {
      case self::uint8:
        return $this->readUInt8();
      case self::int8:
        return $this->readInt8();
      case self::uint16:
        return $this->readUInt16();
      case self::int16:
        return $this->readInt16();
      case self::uint32:
        return $this->readUInt32();
      case self::int32:
        return $this->readUInt32();
      case self::shortFrac:
        return $this->readFixed();
      case self::Fixed:
        return $this->readFixed();
      case self::FWord:
        return $this->readInt16();
      case self::uFWord:
        return $this->readUInt16();
      case self::F2Dot14:
        return $this->readInt16();
      case self::longDateTime:
        return $this->readLongDateTime();
      case self::char:
        return $this->read(1);
      default:
        if (is_array($type)) {
          if ($type[0] == self::char) {
            return $this->read($type[1]);
          }
          if ($type[0] == self::uint16) {
            return $this->readUInt16Many($type[1]);
          }
          if ($type[0] == self::int16) {
            return $this->readInt16Many($type[1]);
          }
          if ($type[0] == self::uint8) {
            return $this->readUInt8Many($type[1]);
          }
          if ($type[0] == self::int8) {
            return $this->readInt8Many($type[1]);
          }

          $ret = array();
          for ($i = 0; $i < $type[1]; $i++) {
            $ret[] = $this->r($type[0]);
          }

          return $ret;
        }

        return null;
    }
  }