public function getCommand($hostConnection = true)
    {
        if (is_null($this->username)) {
            throw new \InvalidArgumentException("You must specify a SSH username");
        }

        if (is_null($this->host)) {
            throw new \InvalidArgumentException("You must specify a SSH host to connect");
        }

        $command = new Command($this->executable);

        if ($this->port != 22) {
            $command->addArgument("p", $this->port);
        }

        if (!is_null($this->privateKey)) {
            $command->addArgument("i", $this->privateKey);
        }

        if ($hostConnection) {
            $command->addParameter($this->getHostConnection());
        }

        return $command;
    }
public function getCommand($hostConnection = true)
    {
        if (is_null($this->username)) {
            throw new \InvalidArgumentException("You must specify a SSH username");
        }

        if (is_null($this->host)) {
            throw new \InvalidArgumentException("You must specify a SSH host to connect");
        }

        $command = new Command($this->executable);

        if ($this->port != 22) {
            $command->addArgument("p", $this->port);
        }

        if (!is_null($this->privateKey)) {
            $command->addArgument("i", $this->privateKey);
        }

        if ($hostConnection) {
            $command->addParameter($this->getHostConnection());
        }

        return $command;
    }
public function getCommand ( $ hostConnection = true ) { if ( is_null ( $ this -> username ) ) { throw new \ InvalidArgumentException ( "You must specify a SSH username" ) ; } if ( is_null ( $ this -> host ) ) { throw new \ InvalidArgumentException ( "You must specify a SSH host to connect" ) ; } $ command = new Command ( $ this -> executable ) ; if ( $ this -> port != 22 ) { $ command -> addArgument ( "p" , $ this -> port ) ; } if ( ! is_null ( $ this -> privateKey ) ) { $ command -> addArgument ( "i" , $ this -> privateKey ) ; } if ( $ hostConnection ) { $ command -> addParameter ( $ this -> getHostConnection ( ) ) ; } return $ command ; }
Gets commands for this SSH connection

@param bool $hostConnection

@return string

@throws \InvalidArgumentException If you don't specify a SSH username or host
Gets commands for this SSH connection