Clinner\Command\Callback::pipe PHP Метод

pipe() публичный Метод

Pipe $anotherCommand to this one, so that this command's output is directly sent to $anotherCommand's standard input.
public pipe ( PipeableCommandInterface $anotherCommand, boolean $appendToPipe = true ) : Clinner\Command\PipingCommandInterface
$anotherCommand PipeableCommandInterface The command to pipe.
$appendToPipe boolean Whether $anotherCommand will be appended to the currently piped commands (TRUE) or if it will be added after this command, rearranging the commands pipe to include it.
Результат Clinner\Command\PipingCommandInterface This instance, for a fluent API.
    public function pipe(PipeableCommandInterface $anotherCommand, $appendToPipe = true)
    {
        if (!$anotherCommand instanceof NullCommand) {
            if ($this === $anotherCommand) {
                // Cannot pipe a command to itself, need to clone it
                $anotherCommand = clone $anotherCommand;
            }
            if ($appendToPipe) {
                if ($this->hasPipedCommand()) {
                    $this->_next->pipe($anotherCommand, true);
                } else {
                    $this->_next = $anotherCommand;
                }
            } else {
                if ($this->hasPipedCommand()) {
                    // Rearrange the commands pipe
                    $anotherCommand->pipe($this->_next, false);
                }
                $this->_next = $anotherCommand;
            }
        }
        return $this;
    }