src/Connection/Replication/SentinelReplication.php
public function switchTo(NodeConnectionInterface $connection)
    {
        if ($connection && $connection === $this->current) {
            return;
        }

        if ($connection !== $this->master && !in_array($connection, $this->slaves, true)) {
            throw new \InvalidArgumentException('Invalid connection or connection not found.');
        }

        $connection->connect();

        if ($this->current) {
            $this->current->disconnect();
        }

        $this->current = $connection;
    }
public function switchTo(NodeConnectionInterface $connection)
    {
        if ($connection && $connection === $this->current) {
            return;
        }

        if ($connection !== $this->master && !in_array($connection, $this->slaves, true)) {
            throw new \InvalidArgumentException('Invalid connection or connection not found.');
        }

        $connection->connect();

        if ($this->current) {
            $this->current->disconnect();
        }

        $this->current = $connection;
    }
public function switchTo ( NodeConnectionInterface $ connection ) { if ( $ connection && $ connection === $ this -> current ) { return ; } if ( $ connection !== $ this -> master && ! in_array ( $ connection , $ this -> slaves , true ) ) { throw new \ InvalidArgumentException ( 'Invalid connection or connection not found.' ) ; } $ connection -> connect ( ) ; if ( $ this -> current ) { $ this -> current -> disconnect ( ) ; } $ this -> current = $ connection ; }
Switches the internal connection in use by the backend.

Sentinel connections are not considered as part of the pool, meaning that
trying to switch to a sentinel will throw an exception.

@param NodeConnectionInterface $connection Connection instance in the pool.
Switches the internal connection in use by the backend .