Checks if the values are in the repository's field list and creates the URL string.

@param string $type
@param array  $value

@throws \InvalidArgumentException

@return string
16846
private function queryAddFieldList(string $type, array $value): string
    {
        $fieldList = [];

        $values = self::ENDPOINT_SINGLE === $type ? $this->valuesSingle : $this->valuesCollection;
        foreach ($value as $parameter) {
            if (!\in_array($parameter, $values, true)) {
                throw new \InvalidArgumentException(\sprintf(
                    'Field %s is not available in the field list for repository %s, try one of %s',
                    $parameter,
                    $this->name,
                    \implode(', ', $values)
                ));
            }

            $fieldList[] = $parameter;
        }

        return \implode(',', $fieldList);
    }
1126396
private function queryAddSortByParameter(array $value): string
    {
        if (!\in_array($value[0], $this->fieldsSortable, true)) {
            throw new \InvalidArgumentException(\sprintf(
                'Parameter %s is not available for sorting in repository %s',
                $value[0],
                $this->name
            ));
        }

        return $value[0].':'.$value[1];
    }
612253
public function https($value) {
		if (strpos($value, $this->baseUrl) === false) {
			throw new InvalidArgumentException("You can only convert existing Gravatar URLs to HTTPS");
		}
		else {
			return str_replace($this->baseUrl, $this->httpsUrl, $value);
		}
	}
534473
public function by($type, $value)
    {
        $this->reloadQueryAdapter();
        $this->activeQuery->triggerLookupMode($type, $value);
        return $this;
    }
1303692
private function validateType($type, $value, $name = '')
    {
        $valueType = gettype($value);
        
        $codeException = $this->checkType($type, $value);
        
        if(1 === $codeException)
        {
            throw new InvalidArgumentException(sprintf('%s argument only accepts %s. Input type was: %s', $name, $type, $valueType));
        }
        
        if(2 === $codeException)
        {
            throw new RuntimeException('The argument is a resource, not is a valid type');
        }
        
        if(3 === $codeException)
        {
            throw new RuntimeException(sprintf('Value not defined in validation for %s', $type));
        }
        
        return $value;
    }
876083
private function validateDefaultTypes($type, $value): bool
    {
        switch ($type) {
            case 'string':
                return is_string($value);
            case 'boolean':
                return is_bool($value);
            case 'integer':
                return is_int($value);
            case 'number':
                return is_numeric($value);
            case 'object':
                return is_object($value);
            case 'array':
                return $this->validateArrayType($value);
            case 'scheme':
                return in_array($value, ['http', 'https', 'ws', 'wss'], true);
            default:
                throw new Exception('Invalid type "' . $type . '"');
        }
    }
1114955
private function assertIsScalarOrArray($value)
    {
        if (! is_scalar($value) && !is_array($value)) {
            throw InvalidTypeException::fromMessageAndPrototype("An unknown type must at least be a scalar or array value", static::prototype());
        }

        if (is_array($value)) {
            foreach ($value as $item) $this->assertIsScalarOrArray($item);
        }
    }
1053493
public function isSpam($type = 'email', $value)
    {
        $fullApiUrl = $this->buildUrl($type, $value);
        $response = $this->sendRequest($fullApiUrl);

        if (! $response) {
            throw new \Exception('API Check Unsuccessful on url: '.$fullApiUrl);
        }

        $result = json_decode($response);

        // check format
        if (! isset($result->success) ||
            ! isset($result->{$type}->appears) ||
            ! isset($result->{$type}->frequency)
        ) {
            logger($response);
            if (is_array($response)) {
                $response = implode(', ', $response);
            }
            throw new \Exception('Response has wrong format: '.$response);
        }

        // check success
        if ($result->success == 1 && $result->{$type}->appears == 1) {
            // check frequency
            return $result->{$type}->frequency >= $this->frequency;
        }

        return false;
    }
620988
private function doDeserializeBaseProperty($type, $value)
    {
        $isAnnotationClass = is_string($type) && is_subclass_of(trim($type, '[]'), AbstractAnnotation::class);

        if ($isAnnotationClass) {
            $isArray = strpos($type, '[') === 0 && substr($type, -1) === ']';

            if ($isArray) {
                $annotationArr = [];
                $class = trim($type, '[]');

                foreach ($value as $v) {
                    $annotationArr[] = $this->doDeserialize($v, $class);
                }
                return $annotationArr;
            }

            return $this->doDeserialize($value, $type);
        }

        return $value;
    }
696725
private function isType(string $type, $value)
    {
        switch ($type) {
            case 'bool':
                return is_bool($value);

            case 'int':
                return is_int($value);

            case 'float':
                return is_float($value) || is_int($value);

            case 'string':
                return is_string($value);

            case 'array':
                return is_array($value);

            default:
                throw new InvalidParamsException('Type match error');
        }
    }
333374
protected function fieldFromRaw($value, $type) {
		switch ($type) {
			case 'int':
			case 'integer':
				return (int)$value;
			case 'float':
				return (float)$value;
			case 'itm':
			case 'item':
				return (int)$value;
			case 'bool':
			case 'boolean':
				return (bool)$value;
			case 'str':
			case 'string':
				return $value;
			case 'binary':
				return bin2hex($value);
			case 'enum':
				return $value;
			case 'dt':
				$obj = NULL;
				if (!empty($value)) {
					$obj = new \Brilliant\BDateTime($value);
				}
				return $obj;
			case 'image':
				if (empty($value)) {
					return NULL;
				}
				$img = new \Brilliant\Images\BImage();
				$img->url = $value;
				return $img;
			case 'json':
				if (empty($value)) {
					return NULL;
				}
				$obj = json_decode($value, true);
				return $obj;
		}
		die('[BItem] fieldFromRaw() Unknown field type "' . $type . '"!');
	}
423761
protected function setValue($value)
    {
        if (is_string($value)) {
            $this->value = $value;
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($value). "' for argument 'value' given."
            );
        }

        return $this;
    }
691045
protected function convertTypeToMask($value, $type)
    {
        if ($this->forceCaseInsensitivity) {
            $value = $this->encoding ? mb_strtolower($value, $this->encoding) : mb_strtolower($value);
        }

        switch ($type) {
            case FilterOperands::STRING_STARTS:
                $value .= '%';
                break;

            case FilterOperands::STRING_ENDS:
                $value = '%' . $value;
                break;

            case FilterOperands::STRING_CONTAINS:
                $value = '%' . $value . '%';
                break;

            case FilterOperands::STRING_EQUALS:
                break;

            default:
                throw new \InvalidArgumentException('Wrong type constant in string like expression mapper');
        }

        return $value;
    }
836791
public function get($type): string
    {
        if (!in_array($type, self::$type, true)) {
            throw new \InvalidArgumentException('Invalid type parameter');
        }

        $content = (string)$this->client
            ->get(UserApi::generateUrl("csv/{$type}.csv"))
            ->getBody();

        return $content;
    }
1362174
public function checkValue(&$value)
    {
        if (is_string($value)) {
            $value = Placeholder::replaceStringsAndComments($value);
            $value = Placeholder::removeCommentPlaceholders($value, true);
            $value = Placeholder::replaceStringPlaceholders($value, true);
            $value = trim($value);

            if ($value !== '') {
                return true;
            } else {
                $this->setIsValid(false);
            }
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($value). "' for argument 'value' given."
            );
        }
    }
991584
public static function encode($value, string $type = null): string
    {
        return self::run(self::ENCODER, $value, $type);
    }
1183444
public function normalizeValue($type, $value)
    {
        if ($value === null) {
            return null;
        }

        if ($type === 'string') {
            return is_string($value) ? $value : (string)$value;
        } elseif ($type === 'int') {
            return is_int($value) ? $value : (int)$value;
        } elseif ($type === 'float') {
            return is_float($value) ? $value : (float)$value;
        } elseif ($type === 'objectid') {
            return is_scalar($type) ? new ObjectID($value) : $value;
        } elseif ($type === 'bool') {
            return is_bool($value) ? $value : (bool)$value;
        } elseif ($type === 'array') {
            return (array)$value;
        } else {
            throw new InvalidValueException(['`:model` model is not supported `:type` type', 'model' => static::class, 'type' => $type]);
        }
    }