src/Bunny/Client.php
public function disconnect($replyCode = 0, $replyText = "")
    {
        if ($this->state === ClientStateEnum::DISCONNECTING) {
            return $this->disconnectPromise;
        }

        if ($this->state !== ClientStateEnum::CONNECTED) {
            return Promise\reject(new ClientException("Client is not connected."));
        }

        $this->state = ClientStateEnum::DISCONNECTING;

        $promises = [];

        if ($replyCode === 0) {
            foreach ($this->channels as $channel) {
                $promises[] = $channel->close();
            }
        }

        return $this->disconnectPromise = Promise\all($promises)->then(function () use ($replyCode, $replyText) {
            if (!empty($this->channels)) {
                throw new \LogicException("All channels have to be closed by now.");
            }

            $this->connectionClose($replyCode, $replyText, 0, 0);
            $this->closeStream();
            $this->init();
            return $this;
        });
    }
public function disconnect($replyCode = 0, $replyText = "")
    {
        if ($this->state === ClientStateEnum::DISCONNECTING) {
            return $this->disconnectPromise;
        }

        if ($this->state !== ClientStateEnum::CONNECTED) {
            return Promise\reject(new ClientException("Client is not connected."));
        }

        $this->state = ClientStateEnum::DISCONNECTING;

        $promises = [];

        if ($replyCode === 0) {
            foreach ($this->channels as $channel) {
                $promises[] = $channel->close();
            }
        }

        return $this->disconnectPromise = Promise\all($promises)->then(function () use ($replyCode, $replyText) {
            if (!empty($this->channels)) {
                throw new \LogicException("All channels have to be closed by now.");
            }

            $this->connectionClose($replyCode, $replyText, 0, 0);
            $this->closeStream();
            $this->init();
            return $this;
        });
    }
public function disconnect ( $ replyCode = 0 , $ replyText = "" ) { if ( $ this -> state === ClientStateEnum :: DISCONNECTING ) { return $ this -> disconnectPromise ; } if ( $ this -> state !== ClientStateEnum :: CONNECTED ) { return Promise \ reject ( new ClientException ( "Client is not connected." ) ) ; } $ this -> state = ClientStateEnum :: DISCONNECTING ; $ promises = [ ] ; if ( $ replyCode === 0 ) { foreach ( $ this -> channels as $ channel ) { $ promises [ ] = $ channel -> close ( ) ; } } return $ this -> disconnectPromise = Promise \ all ( $ promises ) -> then ( function ( ) use ( $ replyCode , $ replyText ) { if ( ! empty ( $ this -> channels ) ) { throw new \ LogicException ( "All channels have to be closed by now." ) ; } $ this -> connectionClose ( $ replyCode , $ replyText , 0 , 0 ) ; $ this -> closeStream ( ) ; $ this -> init ( ) ; return $ this ; } ) ; }
Disconnects from AMQP server.

@param int $replyCode
@param string $replyText
@return Promise\PromiseInterface
Disconnects from AMQP server .