src/AbstractTransport.php
public function withUri($uri)
    {
        if (! $uri instanceof UriInterface) {
            if (!is_string($uri)) {
                throw new InvalidArgumentException(
                    sprintf(
                        'Parameter uri must be as string or instance of %s',
                        UriInterface::class
                    ),
                    E_USER_ERROR
                );
            }

            $uri = new Uri($uri);
        }
        $object = clone $this;
        return $this
            ->buildConfigClient()
            ->withRequest($object->request->withUri($uri));
    }
public function withUri($uri)
    {
        if (! $uri instanceof UriInterface) {
            if (!is_string($uri)) {
                throw new InvalidArgumentException(
                    sprintf(
                        'Parameter uri must be as string or instance of %s',
                        UriInterface::class
                    ),
                    E_USER_ERROR
                );
            }

            $uri = new Uri($uri);
        }
        $object = clone $this;
        return $this
            ->buildConfigClient()
            ->withRequest($object->request->withUri($uri));
    }
With URI

@param string|UriInterface $uri
@return static
@throws InvalidArgumentException