Used to map PHP types to validator types.

@param string $type Data type to unify
@return string unified data type
435529
protected function getValidatorType($type)
    {
        switch ($type) {
            case 'int':
                $type = 'Integer';
                break;
            case 'bool':
                $type = 'Boolean';
                break;
            case 'double':
                $type = 'Float';
                break;
            case 'numeric':
                $type = 'Number';
                break;
            case 'mixed':
                $type = 'Raw';
                break;
            default:
                $type = ucfirst($type);
        }
        return $type;
    }
1077881
private function validateType(string $type): string
    {
        if ('' === $type) {
            throw new \DomainException(sprintf('A type name may not be empty'));
        }

        if ((int) $type) {
            throw new \DomainException(sprintf('A type name may not start with a number. Found %s', $type));
        }

        if (\in_array($type, static::getValidTypes(), true)) {
            // Scalar.
            return $type;
        }

        if ('\\' === $type[0] || ctype_upper($type[0])) {
            // Class.
            return $type;
        }

        throw new \DomainException(sprintf('The type %s is not supported for code generation', $type));
    }
1029563
protected function getSuggestedTypes($type)
    {
        $mapping = [
            'void'    => false,
            'mixed'   => false,
            'null'    => false,
            'int'     => 'int',
            'integer' => 'int',
            'string'  => 'string',
            'float'   => 'float',
            'bool'    => 'bool',
            'boolean' => 'bool',
        ];

        $typeNames = explode('|', $type);
        return array_unique(
            array_map(
                function ($typeName) use ($mapping) {
                    if (isset($mapping[$typeName])) {
                        return $mapping[$typeName];
                    }

                    if ($this->isTypeArray($typeName)) {
                        return 'array';
                    }

                    if ($this->isTypeCallable($typeName)) {
                        return 'callable';
                    }

                    if ($this->isTypeObject($typeName)) {
                        return $typeName;
                    }

                    return false;
                },
                $typeNames
            )
        );
    }
806502
private function converType($type) {
        switch (strtolower($type)) {
            case 'd':
                $typeSum = 'day';
                break;
            case 'm':
                $typeSum = 'month';
                break;
            case 'y':
                $typeSum = 'year';
                break;
            case 'h':
                $typeSum = 'hour';
                break;
            case 'i':
                $typeSum = 'minute';
                break;
            case 's':
                $typeSum = 'second';
                break;
        }
        return $typeSum;
    }
290438
private function mapType($type)
    {
        $types = [
            Gmagick::IMGTYPE_BILEVEL              => 'BILEVEL',
            Gmagick::IMGTYPE_GRAYSCALE            => 'GRAYSCALE',
            Gmagick::IMGTYPE_GRAYSCALEMATTE       => 'GRAYSCALEMATTE',
            Gmagick::IMGTYPE_PALETTE              => 'PALETTE',
            Gmagick::IMGTYPE_PALETTEMATTE         => 'PALETTEMATTE',
            Gmagick::IMGTYPE_TRUECOLOR            => 'TRUECOLOR',
            Gmagick::IMGTYPE_TRUECOLORMATTE       => 'TRUECOLORMATTE',
            Gmagick::IMGTYPE_COLORSEPARATION      => 'COLORSEPARATION',
            Gmagick::IMGTYPE_COLORSEPARATIONMATTE => 'COLORSEPARATIONMATTE',
            Gmagick::IMGTYPE_OPTIMIZE             => 'OPTIMIZE',
            Gmagick::IMGTYPE_UNDEFINED            => 'UNDEFINED',
        ];

        if (!isset($types[$type])) {
            return $types[Gmagick::IMGTYPE_UNDEFINED];
        }

        return $types[$type];
    }
40473
public function type($type)
    {
        $fail = false;

        $value = $this->value();

        if ($value === null) {
            return $this;
        }

        switch (strtolower($type)) {
            case 'bool':
            case 'boolean':
                if ($fail = !is_bool($value)) {
                    $message = sprintf('%s accepts only boolean values as argument %d.', $this->getCommandName(),
                        $this->key + 1);
                }
                break;

            case 'int':
            case 'integer':
                if ($fail = !is_int($value)) {
                    $message = sprintf('%s accepts only integer values as argument %d.', $this->getCommandName(),
                        $this->key + 1);
                }
                break;

            case 'num':
            case 'numeric':
                $fail = !is_numeric($value);
                $message = sprintf('%s accepts only numeric values as argument %d.', $this->getCommandName(),
                    $this->key + 1);
                break;

            case 'str':
            case 'string':
                if ($fail = !is_string($value)) {
                    $message = sprintf('%s accepts only string values as argument %d.', $this->getCommandName(),
                        $this->key + 1);
                }
                break;

            case 'array':
                if ($fail = !is_array($value)) {
                    $message = sprintf('%s accepts only array as argument %d.', $this->getCommandName(),
                        $this->key + 1);
                }
                break;

            case 'closure':
                if ($fail = !$value instanceof \Closure) {
                    $message = sprintf('%s accepts only Closure as argument %d.', $this->getCommandName(),
                        $this->key + 1);
                }
                break;

            case 'digit':
                if ($fail = !$this->isDigit($value)) {
                    $message = sprintf('%s accepts only integer values as argument %d.', $this->getCommandName(),
                        $this->key + 1);
                }
                break;
        }

        if ($fail) {
            $message = $message ?? sprintf('Missing argument for %d.', $this->key);

            throw new \Hail\Image\Exception\InvalidArgumentException($message);
        }

        return $this;
    }
382494
private static function validateMiddlewareType(string $type) : string
  {
    if (!in_array($type, self::MIDDLEWARE_TYPES)) {
      throw new \InvalidArgumentException(sprintf(
        'Provided middleware type does not exist. Use one of %s instead.',
        implode(', ', self::MIDDLEWARE_TYPES)
      ));
    }

    return $type;
  }
932584
public function mapResponseToType($type) {

        if (!empty($this->rawData)) {

            foreach ($this->rawData as $dataSet) {

                if (!is_array($dataSet)) {
                    $this->data = (new $type())->initFromArray($this->rawData);
                    break;
                }

                $this->data[] = (new $type())->initFromArray($dataSet);

            }

        }

        if (!empty($this->rawData['before'])) {
            $this->data->setBefore($this->rawData['before']);
        }

        if (!empty($this->rawData['after'])) {
            $this->data->setAfter($this->rawData['before']);
        }

        if (!empty($this->rawData['message'])) {
            $this->data->setMessage($this->rawData['message']);
        }

        return $this;

    }
651830
protected function resolveType($type)
    {
        switch ($type) {
            case IndexMapping::TYPE_BOOLEAN:
                return ["type" => "boolean"];

            case IndexMapping::TYPE_FLOAT:
                return ["type" => "float"];

            case IndexMapping::TYPE_INTEGER:
                return ["type" => "integer"];

            case IndexMapping::TYPE_DATE:
                return ["type" => "date", "format" => "YYYY-MM-dd"];

            case IndexMapping::TYPE_DATETIME:
                return ["type" => "date"];

            case IndexMapping::TYPE_TIME:
                return ["type" => "date", "format" => "HH:mm:ss"];

            default:
            case IndexMapping::TYPE_STRING:
            case IndexMapping::TYPE_BIG_TEXT:
                return ["type" => "string", "analyzer" => "standard"];
        }
    }
1225150
protected function typeToString($type)
    {

        if (is_object($type)) {
            return sprintf('Object::%s', get_class($type));
        }

        if (is_array($type)) {
            $types = [];

            /** @noinspection ForeachSourceInspection */
            foreach ($type as $key => $item) {
                $types[] = sprintf('%s => %s', $key, $this->typeToString($item));
            }

            return 'Array(' . implode(', ', $types) . ')';
        }

        if (is_bool($type)) {
            return sprintf('Boolean::%s', $type ? 'True' : 'False');
        }

        if (is_int($type) || is_float($type)) {
            return sprintf('Integer::%s', (string) $type);
        }

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

        return "'$type'";
    }
48624
private function parseCastToValidator($type)
    {
        if (array_has(static::$cast_validation, $type)) {
            return array_get(static::$cast_validation, $type);
        }

        if (array_has(static::$default_cast_validation, $type)) {
            return array_get(static::$default_cast_validation, $type);
        }

        return $type;
    }
260648
public function getClassForType(string $type):?string
    {
        if (isset($this->typeMap[$type])) {
            return $this->typeMap[$type];
        }

        return null;
    }
331464
static function getArrayType($type){
        self::isArray($type) or \PhpBoot\abort(new \InvalidArgumentException("$type is not array"));
        if($type == 'array') {
            return 'mixed';
        }else{
            return substr($type,0,-2);
        }
    }
1167186
public static function getPhpType($type)
    {
        switch ($type) {
            case self::TYPE_DOUBLE:
            case self::TYPE_FLOAT:
                return 'float';
            case self::TYPE_INT64:
            case self::TYPE_UINT64:
            case self::TYPE_INT32:
            case self::TYPE_FIXED64:
            case self::TYPE_FIXED32:
            case self::TYPE_UINT32:
            case self::TYPE_SFIXED32:
            case self::TYPE_SFIXED64:
            case self::TYPE_SINT32:
            case self::TYPE_SINT64:
                return 'int';
            case self::TYPE_BOOL:
                return 'bool';
            case self::TYPE_STRING:
                return 'string';
            case self::TYPE_BYTES:
                return '\Protobuf\Stream';
            default:
                return null;
        }
    }
687958
private function _getFormType($type)
	{
		$formType = 'text';
		switch($type)
		{
			case "boolean":
			case "bool":
				$formType = 'checkbox';
				break;
			case "array":
				$formType = 'multiCheckbox';
				break;
			case "date":
				$formType = 'date';
				break;
			case "datetime":
				$formType = 'datetime';
				break;
			case "time":
				$formType = 'time';
				break;
			case "uint":
			case "int":
				$formType = 'int';
				break;
			case "float":
				$formType = 'float';
				break;
			case "email":
				$formType = 'email';
				break;
			case "host":
				$formType = 'host';
				break;
			case "text":
				$formType = 'text';
				break;
			case "currency":
				$formType = 'currency';
				break;
			case "country":
				$formType = 'country';
				break;
			case "hidden":
				$formType = 'hidden';
				break;
			default:
				debug_assert(false !== array_search($type, self::$types), "Unknown Form Type `{$type}`");
				break;
		}

		return $formType;
	}
731423
public function getTypeValidator($type)
    {
        if (in_array($type, $this->allowedTypeValidators, true) == false) {
            throw new InvalidTypeValidatorException('The type "'.$type.'" is invalid');
        }

        if (isset($this->typeValidators[$type]) == false) {
            $className = 'Mooti\\Validator\\TypeValidator\\'.ucfirst($type).'Validator';
            $this->typeValidators[$type] = $this->createNew($className);
        }

        return $this->typeValidators[$type];
    }
86403
protected function _validateLoaderType($type)
    {
        $type = strtolower($type);
        if (!in_array($type, $this->_loaderTypes)) {
            $types = implode(', ', $this->_loaderTypes);

            throw new Zend_Http_UserAgent_Exception(sprintf(
                'Expected one of "%s" for plugin loader type; received "%s"',
                $types,
                (string) $type
            ));
        }
        return $type;
    }