protected function setPort($port)
    {
        $this->uriString = null;

        if (null === $port) {
            $this->port = null;

            return $this;
        }

        if (! $this->isPortValid($port)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid port "%s" provided.',
                (is_object($port) ? get_class($port) : gettype($port))
            ));
        }
        $this->port = (int) $port;

        return $this;
    }