@param string $type One of "condition", "token", "topic"
@param string $value

@throws InvalidArgumentException if the target type or value is invalid

@return CloudMessage
189047
public static function withTarget(string $type, string $value): self
    {
        return (new self())->withChangedTarget($type, $value);
    }
1182686
public function expects($type, $value = null)
    {
        $token = $this->tokens[$this->cursor];

        if (($value === null ? $token->is($type) : $token->equals($type, $value)) === false) {
            throw new UnexpectedTokenException($this, new Token($type, $value));
        }

        return $this->tokens[$this->cursor++];
    }
32158
public function setRecipientGatewayId($value)
    {
        if ($value === null || $value === '') {
            $this->_recipientGatewayId = null;
        } elseif (TypeCast::canCastToString($value)) {
            $this->_recipientGatewayId = (string)$value;
        } else {
            throw new InvalidPropertyValueTypeException(
                'Invalid recipientGatewayId value type in PaymentsRequest', 0, 'PaymentsRequest.recipientGatewayId',
                $value
            );
        }
    }
599601
protected static function ensureType($type, $value, $errorMessage)
    {
        if (!($value instanceof $type)) {
            throw new PdfTypeException(
                $errorMessage,
                PdfTypeException::INVALID_DATA_TYPE
            );
        }

        return $value;
    }
1076125
public static function isResource($value, $message = null)
    {
        if (!is_resource($value)) {
            throw new InvalidArgumentException(sprintf(
                $message ?: 'Expected resource, but got %s',
                Helper::typeToString($value)
            ));
        }
    }
1052500
public function setAuth($type, $value)
    {
        switch ($type) {
            case self::AUTH_BASIC:
                // The use of base64 encoding for authorization headers follow the RFC 2617 standard for http
                // authentication (https://www.ietf.org/rfc/rfc2617.txt).
                $this->addHeader(
                    self::HEADER_AUTHORIZATION,
                    'Basic ' . base64_encode(implode(':', $value))
                );
                break;

            case self::AUTH_BEARER:
                $this->addHeader(self::HEADER_AUTHORIZATION, 'Bearer ' . $value);
                break;

            default:
                throw new NostoException('Unsupported auth type.');
        }
    }
950321
protected function setMessage($type, $translationString, $value)
    {
        $text = is_array($value) ? implode(',', $value) : $value;
        $this->getIo()->{$type}(
            sprintf(
                $this->trans($translationString),
                $text
            )
        );
    }
710650
public function setValue($value)
    {
        if (is_string($value) === true) {
            $this->value = $value;
        } else {
            $msg = "The 'value' argument must be a string, '" . gettype($value) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
542878
public function setBinding($number, $value, $type = 'where')
	{
		if (! array_key_exists($type, $this->bindings))
		{
			throw new InvalidArgumentException("Invalid binding type: {$type}.");
		}

		$number = (int) $number;
		if( !isset($this->bindings[$type][$number]) )
		{
			throw new InvalidArgumentException("Invalid binding number parameter: {$number}.");
		}

		$this->bindings[$type][$number] = $value;
		return $this;
	}
103100
protected function toPhpType($value, $type)
    {
        switch ($type) {
            case 'int':
                return (int) $value;

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

            case 'datetime':
                return $value === '0000-00-00 00:00:00' ? '' : $value;

            case 'date':
                return $value === '0000-00-00' ? '' : $value;

            case 'bool':
                return (bool) $value;

            case 'array':
            case 'json':
                // Ignore default array value
                return is_array($value) ? $value : $this->cacheJsonDecode($value, true);

            case 'float':
                return (float) $value;

            default:
                throw new InvalidArgumentException('Unsupported cast type: ' . $type);
        }
    }
1235249
public function offsetSet($offset, $value)
    {
        if (!$value instanceof Token) {
            throw new \InvalidArgumentException('Value must be of type Token.');
        }

        if ($offset === null) {
            $this->tokens[] = $value;

            return;
        }

        $this->tokens[$offset] = $value;
    }
484764
protected function typecastValue($value, $type)
    {
        if (is_scalar($type)) {
            if (is_object($value) && method_exists($value, '__toString')) {
                $value = $value->__toString();
            }

            switch ($type) {
                case self::TYPE_INTEGER:
                    return (int)$value;
                case self::TYPE_FLOAT:
                    return (float)$value;
                case self::TYPE_BOOLEAN:
                    return (bool)$value;
                case self::TYPE_STRING:
                    return (string)$value;
                case self::TYPE_JSON:
                    return is_string($value) ? $value : json_encode($value);
                case self::TYPE_IMPLODE:
                    return is_string($value) ? $value : (string)implode($this->delimiter, $value);
                case self::TYPE_SERIALIZE:
                    return is_string($value) ? $value : serialize($value);
                default:
                    throw new InvalidParamException("Unsupported type '{$type}'");
            }
        }

        return call_user_func($type, $value);
    }
1138218
protected function checkValueStructure(BaseValue $value)
    {
        if (!is_int($value->destinationContentId) && !is_string($value->destinationContentId)) {
            throw new InvalidArgumentType(
                '$value->destinationContentId',
                'string|int',
                $value->destinationContentId
            );
        }
    }
864673
protected function checkValueStructure(BaseValue $value)
    {
        if (!is_array($value->destinationContentIds)) {
            throw new InvalidArgumentType(
                '$value->destinationContentIds',
                'array',
                $value->destinationContentIds
            );
        }

        foreach ($value->destinationContentIds as $key => $destinationContentId) {
            if (!is_int($destinationContentId) && !is_string($destinationContentId)) {
                throw new InvalidArgumentType(
                    "\$value->destinationContentIds[$key]",
                    'string|int',
                    $destinationContentId
                );
            }
        }
    }
355565
public function attach($value, $capture = null)
    {
        if (null === $capture) {
            $capture = $this->captureType;
        }

        switch ($capture) {
            case self::APPEND:
                $this->append($value);
                break;
            case self::PREPEND:
                $this->prepend($value);
                break;
            case self::SET:
                $this->set($value);
                break;
            default:
                throw new InvalidArgumentException(sprintf(
                    'Invalid capture type provided; must be any of the capture '
                    . 'type constants, "%s" received.',
                    is_scalar($capture) ? $capture : gettype($capture)
                ));
        }

        return $this;
    }
240249
public static function param(Type $type = null, $value) : Parameter
    {
        if ($value instanceof Expr) {
            throw InvalidArgumentException::format('Parameter cannot be class of %s', get_class($value));
        }

        return new Parameter($type ?? Type::fromValue($value), $value);
    }
1273155
private function setEqLevel(string $type, int $value): SpeakerInterface
    {
        if ($value < -10) {
            $value = -10;
        }
        if ($value > 10) {
            $value = 10;
        }

        $type = ucfirst(strtolower($type));
        $this->soap("RenderingControl", "Set{$type}", [
            "Channel"           =>  "Master",
            "Desired{$type}"    =>  $value,
        ]);

        return $this;
    }