Normalize rateable model type.

@param string $modelType
@return string

@throws \InetStudio\Rating\Exceptions\ModelInvalidException
500008
protected function normalizeModelType($modelType)
    {
        $morphMap = Relation::morphMap();

        if (class_exists($modelType)) {
            $model = new $modelType;
            $modelType = $model->getMorphClass();
        } else {
            if (! isset($morphMap[$modelType])) {
                throw new ModelInvalidException("[$modelType] class and morph map are not found.");
            }

            $modelClass = $morphMap[$modelType];
            $model = new $modelClass;
        }

        if (!$model instanceof RateableContract) {
            throw new ModelInvalidException("[$modelType] not implements Rateable contract.");
        }

        return $modelType;
    }
263785
public function type(string $readModelType)
    {
        if (!is_subclass_of($readModelType, IReadModel::class, true)) {
            throw InvalidArgumentException::format(
                'Invalid class supplied to read model mapper definition: expecting instance of %s, %s given',
                IReadModel::class, $readModelType
            );
        }

        $this->readDefinition->type($readModelType);
        /** @var string|IReadModel|TypedObject $readModelType */
        $this->class = $readModelType::definition();
    }
607128
protected function normalizeCriteria($criteria) {
		if ($criteria instanceof Criteria) {
			return $criteria->assemble();
		}
		
		if (is_array($criteria)) {
			return $criteria;
		}
		
		throw new Exceptions\InvalidCriteria('Invalid type of the criteria: "' . gettype($criteria) . '"');
	}
791904
public function entityGetAttrType($demAttrType)
    {
        $result = MageType::COL_TEXT;
        $type = key($demAttrType);
        $typeData = reset($demAttrType);
        switch ($type) {
            case DemType::ATTR_BINARY:
                $result = MageType::COL_BLOB;
                break;
            case DemType::ATTR_BOOLEAN:
                $result = MageType::COL_BOOLEAN;
                break;
            case DemType::ATTR_DATETIME:
                $result = MageType::COL_TIMESTAMP;
                break;
            case DemType::ATTR_INTEGER:
                $result = MageType::COL_INTEGER;
                if (isset($typeData[Cfg::SUBTYPE])) {
                    if ($typeData[Cfg::SUBTYPE] == DemType::ATTRSUB_SMALL_INT) {
                        $result = MageType::COL_SMALLINT;
                    }
                }
                break;
            case DemType::ATTR_NUMERIC:
                $result = MageType::COL_DECIMAL;
                break;
            case DemType::ATTR_OPTION:
                $result = MageType::COL_TEXT;
                break;
            case DemType::ATTR_TEXT:
                $result = MageType::COL_TEXT;
                break;
        }
        return $result;
    }
7105
protected function checkServiceType($serviceType)
    {
        $reflection = new \ReflectionObject($this);
        $constants = $reflection->getConstants();
        if (!in_array($serviceType, $constants)) {
            throw new RuntimeException('The type of service does not support: ' . $serviceType);
        }
        return $serviceType;
    }
783186
public function getDefaultValue()
    {
        if ($this->isDefaultValueAvailable()) {
            $prettyPrinter = new PrettyPrinter\Standard;
            return $prettyPrinter->prettyPrintExpr($this->node->default);
        }
        throw new ModelException(
            sprintf(
                'Parameter #%d [$%s] is not optional.',
                $this->getPosition(),
                $this->getName()
            )
        );
    }
240047
protected function cleanType(?string $type): ?string
    {
        if (!$type || in_array(strtolower($type), ['null', 'mixed']) || strpos($type, '|')) {
            return null;
        }
        $lowerType = strtolower($type);
        if (in_array(ltrim($lowerType, '?'), [
            'array', 'int', 'integer', 'bool', 'boolean', 'float', 'double', 
            'real', 'string', 'object', 'unset', 'callback'
        ])) {
            return $lowerType;
        }
        return '\\' . ltrim($type, '\\');
    }
567339
protected function normalizeCriteria($criteria) {
		if ($criteria === null) {
			return;
		}
		
		if ($criteria instanceof Criteria) {
			return $criteria->getInnerCriteria()->getParams();
		}
		
		if ($criteria instanceof PhalconCriteria) {
			return $criteria->getParams();
		}
		
		if (is_array($criteria) || is_string($criteria) || is_int($criteria)) {
			return $criteria;
		}
		
		throw new InvalidCriteria('Invalid type of the criteria: "' . gettype($criteria) . '"');
	}
471585
protected function normalizeFollowableType($type)
    {
        $morphMap = Relation::morphMap();

        if (!empty($morphMap) && in_array($type, $morphMap, true)) {
            $type = array_search($type, $morphMap, true);
        }

        if (class_exists($type)) {
            return $type;
        }

        $namespace = config('follow.model_namespace', 'App');

        $modelName = $namespace.'\\'.studly_case($type);

        if (!class_exists($modelName)) {
            throw new InvalidArgumentException("Model {$modelName} not exists. Please check your config 'follow.model_namespace'.");
        }

        return $modelName;
    }
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;
    }
69940
protected function _checkFieldType($modelFieldName = null) {
		if (empty($modelFieldName) || !is_string($modelFieldName)) {
			return false;
		}

		if (strpos($modelFieldName, '.') === false) {
			return false;
		}

		list($modelName, $fieldName) = pluginSplit($modelFieldName);
		$schema = $this->_getSchemaForModel($modelName);
		if (($schema === null) || !is_array($schema) || !isset($schema[$fieldName]['type']) ||
			!in_array($schema[$fieldName]['type'], ['text', 'string'])) {
			return false;
		}

		return true;
	}
1255368
public static function queryByTypeParentTypeModelId( $type, $parentType, $modelId ) {

		return self::find()->where( 'type=:type AND parentType=:ptype AND modelId=:mid', [ ':type' => $type, ':parentType' => $parentType, ':mid' => $modelId ] );
	}
86494
protected function normalizeMode($type, $mode)
    {
        $normalizedMode = null;
        
        if (is_int($mode)) {
            $normalizedMode = $mode;
        } elseif (null !== $mode) {
            if (!is_array($mode)) {
                $mode = [$mode];
            }
            
            foreach ($mode as $m) {
                switch ($m) {
                    case 'optional':
                        if ($type == 'option') {
                            $value = InputOption::VALUE_OPTIONAL;
                        } else {
                            $value = InputArgument::OPTIONAL;
                        }
                        if (null === $normalizedMode) {
                            $normalizedMode = $value;
                        } else {
                            $normalizedMode = $normalizedMode | $value;
                        }
                        break;
                    
                    case 'required':
                        if ($type == 'option') {
                            $value = InputOption::VALUE_REQUIRED;
                        } else {
                            $value = InputArgument::REQUIRED;
                        }
                        if (null === $normalizedMode) {
                            $normalizedMode = $value;
                        } else {
                            $normalizedMode = $normalizedMode | $value;
                        }
                        break;
                    
                    case 'array':
                        if ($type == 'option') {
                            $value = InputOption::VALUE_IS_ARRAY;
                        } else {
                            $value = InputArgument::IS_ARRAY;
                        }
                        if (null === $normalizedMode) {
                            $normalizedMode = $value;
                        } else {
                            $normalizedMode = $normalizedMode | $value;
                        }
                        break;
                    
                    case 'none':
                        if ($type == 'option') {
                            if (null === $normalizedMode) {
                                $normalizedMode = InputOption::VALUE_NONE;
                            } else {
                                $normalizedMode = $normalizedMode | InputOption::VALUE_NONE;
                            }
                        }
                        break;
                    
                    default:
                        throw new Exception\InvalidArgumentException(
                            sprintf(
                                "Mode must be either 'none', 'optional', 'required' or 'array', passed '%s'",
                                $m
                            )
                        );
                        break;
                }
            }
        }
        
        return $normalizedMode;
    }
964918
protected function normalize($config)
    {
        // Validate the config entry
        $this->validateRootElements($config);

        // For single value elements, normalize all class name and options, remove null entry
        foreach (array('vcs', 'version-generator', 'version-persister') as $configKey) {
            $value = $config[$configKey];
            if ($value == null) {
                unset($config[$configKey]);
                continue;
            }
            $config[$configKey] = $this->getClassAndOptions($value, $configKey);
        }

        // Same process but for list value elements
        foreach (array('prerequisites', 'pre-release-actions', 'post-release-actions') as $configKey) {
            foreach ($config[$configKey] as $key => $item) {

                // Accept the element to be define by key or by value
                if (!is_numeric($key)) {
                    if ($item == null) {
                        $item = array();
                    }
                    $item['name'] = $key;
                }

                $config[$configKey][$key] = $this->getClassAndOptions($item, $configKey.'_'.$key);
            }
        }

        return $config;
    }
1039858
public static Class normalizeType(Class type) {
		SimonType simonType = SimonTypeFactory.getValueFromType(type);
		Class normalizedType;
		if (simonType == null) {
			simonType = SimonTypeFactory.getValueFromSampleType(type);
			if (simonType == null) {
				normalizedType = type;
			} else {
				normalizedType = simonType.getSampleType();
			}
		} else {
			normalizedType = simonType.getType();
		}
		return normalizedType;
	}
1283302
protected function getEvaluatorByMatchType($matchType)
    {
        $evaluatorsByMatchType = array();
        $evaluatorsByMatchType[self::EXACT_MATCH_TYPE] = 'exactEvaluator';
        $evaluatorsByMatchType[self::EXISTS_MATCH_TYPE] = 'existsEvaluator';
        $evaluatorsByMatchType[self::GREATER_THAN_MATCH_TYPE] = 'greaterThanEvaluator';
        $evaluatorsByMatchType[self::LESS_THAN_MATCH_TYPE] = 'lessThanEvaluator';
        $evaluatorsByMatchType[self::SUBSTRING_MATCH_TYPE] = 'substringEvaluator';

        return $evaluatorsByMatchType[$matchType];
    }
109929
public static function get_request_type_string($requesttype) {
        $types = self::get_request_types();
        if (!isset($types[$requesttype])) {
            throw new moodle_exception('errorinvalidrequesttype', 'tool_dataprivacy');
        }
        return $types[$requesttype];
    }