Run a set of commands against the connection.

@param string|array $commands
@param \Closure     $callback

@return void
160180
public function run($commands, Closure $callback = null)
    {
        foreach ($this->connections as $connection) {
            $connection->run($commands, $callback);
        }
    }
1274362
protected function run(array $query, Closure $callback)
    {
        $start = microtime(true);

        // Here we will run this query. If an exception occurs we'll determine a
        // few basic scenarios and create an appropriate response for them.
        $result = $this->runQueryCallback($query, $callback);

        // Once we have ran the query we will calculate the time that it took to run and
        // then log the query and execution time so we will report them on
        // the event that the developer needs them. We'll log time in milliseconds.
        $time = $this->getElapsedTime($start);

        $this->logQuery($query, $time);

        return $result;
    }
1064476
public function executeCommand($cmd, \Closure $closure = null, Process $process = null)
    {
        try {
            $cmd = $this->php.' '.$this->console.' '.$cmd;
            if (null === $process) {
                $process =  new Process($cmd);
            } else {
                $process->setCommandLine($cmd);
            }

            return $process->run($closure);
        } catch (\Exception $e) {
            return false;
        }
    }
1144100
public function run($commands, Closure $callback = null)
    {
        $gateway = $this->getGateway();
        $commands = is_array($commands) ? implode(' && ', $commands) : $commands;
        if ($this->connectionKey->isFtp()) {
            return;
        }

        $gateway->exec($commands, $callback);
        if ($gateway->isTimeout()) {
            throw new TimeOutException($gateway->timeout);
        }
    }
698405
public function psubscribe( $channels, Closure $callback, $connection = null )
	{
		$this->subscribe( $channels, $callback, $connection, __FUNCTION__ );
	}
140824
protected function registerCommands(array $commands)
    {
        foreach (array_keys($commands) as $command) {
            call_user_func([$this, "register{$command}Command"]);
        }

        $this->commands(array_values($commands));
    }
458680
public function execute(callable $callback)
    {
        $commands = $this->commands;
        $command  = $this->client->createCommand('EXEC');

        $this->client->executeCommand($command, function ($responses, $client) use ($commands, $callback) {
            $size = count($responses);
            $processed = [];

            for ($i = 0; $i < $size; $i++) {
                $command  = $commands->dequeue();
                $response = $responses[$i];

                unset($responses[$i]);

                if (!$response instanceof ResponseInterface) {
                    $response = $command->parseResponse($response);
                }

                $processed[$i] = $response;
            }

            call_user_func($callback, $processed, $client);
        });
    }
1059314
public function run($commands, $callback = null)
	{
		if (!$this->ssh->isConnected())
			throw new NotConnectedException();

		if (is_array($commands))
			$commands = implode(' && ', $commands);

		if ($callback === null)
			$output = '';

		$this->ssh->exec($commands, false);

		while (true) {
			if (is_null($line = $this->readLine())) break;

			if ($callback === null)
				$output .= $line;
			else
				call_user_func($callback, $line, $this);
		}

		if ($callback === null)
			return $output;
		else
			return null;
	}
669798
public function runCallback( \Closure $callback, $postReinitialize = true )
    {
        $this->requestInit();

        try
        {
            $return = $callback();
        }
        catch ( Exception $e )
        {
            $this->shutdown( $postReinitialize );
            throw $e;
        }

        $this->shutdown( $postReinitialize );

        return $return;
    }
1169859
public static function register($command, $callback)
    {
        if (!is_string($command) || strlen($command) < 1) {
            throw new BadMethodCallException('Parameter command is not a valid string');
        }
        if (!is_callable($callback)) {
            throw new BadMethodCallException('Parameter callback is not a valid callback');
        }

        $instance = self::getInstance();
        
        $instance->commands[$command] = $callback;
        
        return $instance;
    }
392613
public function command($signature, \Closure $callback)
    {
        $command = new ClosureCommand($signature, $callback);

        Console::starting(function ($console) use ($command) {
            $console->add($command);
        });

        return $command;
    }
1129076
public function psubscribe($channels, Closure $callback)
    {
        $this->client->psubscribe((array) $channels, function ($redis, $pattern, $channel, $message) use ($callback) {
            $callback($message, $channel);
        });
    }
434113
public function whenBooted(\Closure $callback)
    {
        $this->bootCallbacks[] = $callback;

        if ($this->isBooted()) {
            fire_callbacks([$callback], $this);
        }
    }
258078
public function execute(\Closure $callback = null)
    {
        $stacks = $this->buildStacks();

        foreach ($stacks as $requests) {
            foreach ($requests as $request) {
                $status = curl_multi_add_handle($this->handle, $request->getHandle());
                if ($status !== CURLM_OK) {
                    throw new \Exception(sprintf(
                        'Unable to add request to cURL multi handle (code #%u)',
                        $status
                    ));
                }
            }

            $this->dispatch();

            foreach ($requests as $request) {
                $request->setRawResponse(curl_multi_getcontent($request->getHandle()));
                curl_multi_remove_handle($this->handle, $request->getHandle());

                if ($callback !== null) {
                    $callback($request->getResponse());
                }
            }
        }
    }
74488
public static function some(array $set, Closure $callback) {
        foreach ($set as $value) {
            if ($callback($value, $value)) {
                return true;
            }
        }

        return false;
    }
813573
public function executeCommands(array $commands, \Closure $closure = null, Process $process = null)
    {
        foreach ($commands as $command => $commandClosure) {
            $currentClosure = (null !== $commandClosure) ? $commandClosure : $closure;
            $processResult = $this->executeCommand($command, $currentClosure, $process);
            if ($processResult === -1 || $processResult === 255) {
                return false;
            }
        }

        return true;
    }
127778
public function unregisterCallback($commands, $callback = null)
    {
        $commands  = (array) $commands;

        foreach ($commands as $command) {
            $command = strtolower($command);

            if (isset($this->_callbacks[$command])) {
                if ($callback) {
                    $key = array_search($callback, $this->_callbacks[$command], true);
                    if ($key !== false) {
                        unset($this->_callbacks[$command][$key]);
                        unset($this->_params[$command][$key]);
                    }
                } else {
                    unset($this->_callbacks[$command]);
                    unset($this->_params[$command]);
                }
            }
        }

        return $this->_mixer;
    }