public function run()
    {
        //Bogus variable set. The original value is never used, but IDEs complain
        $result = new Result();
        $resultArray = array();
        $max = count($this->commands);

        for ($i = 0; $i < $max; ++$i) {
            $cmd = $this->commands[$i];

            if ($i === 0) {
                $resultArray[] = $result = $cmd->run();
                continue;
            }

            if (($cmd->_runMode === RUN_IF_PREVIOUS_SUCCEEDS && $result->getExitCode() !== 0) ||
                ($cmd->_runMode === RUN_IF_PREVIOUS_FAILS && $result->getExitCode() === 0)
            ) {
                continue;
            }

            if ($cmd->_pipe) {
                $stdOut = trim($result->getStdOut());

                $isXArg = false;
                foreach ($cmd as $argIdx => $arg) {
                    if ($arg instanceof Argument) {
                        if (stripos($arg->getKey(true), PIPE_PH) !== false) {
                            $key = str_replace(PIPE_PH, $stdOut, $arg->getKey(true));
                            $arg->setKey($key);
                        }

                        $values = $arg->getValues();
                        foreach ($values as $index => $val) {
                            if (stripos($val, PIPE_PH) !== false) {
                                $val = str_replace(PIPE_PH, $stdOut, $val);
                                $arg->replaceValue($index, $val);
                                $isXArg = true;
                            }
                        }
                    }
                }
                if (!$isXArg) {
                    $cmd->setStdIn($stdOut);
                }
            }

            $resultArray[] = $result = $cmd->run();
        }

        return $resultArray;
    }
public function run()
    {
        //Bogus variable set. The original value is never used, but IDEs complain
        $result = new Result();
        $resultArray = array();
        $max = count($this->commands);

        for ($i = 0; $i < $max; ++$i) {
            $cmd = $this->commands[$i];

            if ($i === 0) {
                $resultArray[] = $result = $cmd->run();
                continue;
            }

            if (($cmd->_runMode === RUN_IF_PREVIOUS_SUCCEEDS && $result->getExitCode() !== 0) ||
                ($cmd->_runMode === RUN_IF_PREVIOUS_FAILS && $result->getExitCode() === 0)
            ) {
                continue;
            }

            if ($cmd->_pipe) {
                $stdOut = trim($result->getStdOut());

                $isXArg = false;
                foreach ($cmd as $argIdx => $arg) {
                    if ($arg instanceof Argument) {
                        if (stripos($arg->getKey(true), PIPE_PH) !== false) {
                            $key = str_replace(PIPE_PH, $stdOut, $arg->getKey(true));
                            $arg->setKey($key);
                        }

                        $values = $arg->getValues();
                        foreach ($values as $index => $val) {
                            if (stripos($val, PIPE_PH) !== false) {
                                $val = str_replace(PIPE_PH, $stdOut, $val);
                                $arg->replaceValue($index, $val);
                                $isXArg = true;
                            }
                        }
                    }
                }
                if (!$isXArg) {
                    $cmd->setStdIn($stdOut);
                }
            }

            $resultArray[] = $result = $cmd->run();
        }

        return $resultArray;
    }
public function run ( ) { //Bogus variable set. The original value is never used, but IDEs complain $ result = new Result ( ) ; $ resultArray = array ( ) ; $ max = count ( $ this -> commands ) ; for ( $ i = 0 ; $ i < $ max ; ++ $ i ) { $ cmd = $ this -> commands [ $ i ] ; if ( $ i === 0 ) { $ resultArray [ ] = $ result = $ cmd -> run ( ) ; continue ; } if ( ( $ cmd -> _runMode === RUN_IF_PREVIOUS_SUCCEEDS && $ result -> getExitCode ( ) !== 0 ) || ( $ cmd -> _runMode === RUN_IF_PREVIOUS_FAILS && $ result -> getExitCode ( ) === 0 ) ) { continue ; } if ( $ cmd -> _pipe ) { $ stdOut = trim ( $ result -> getStdOut ( ) ) ; $ isXArg = false ; foreach ( $ cmd as $ argIdx => $ arg ) { if ( $ arg instanceof Argument ) { if ( stripos ( $ arg -> getKey ( true ) , PIPE_PH ) !== false ) { $ key = str_replace ( PIPE_PH , $ stdOut , $ arg -> getKey ( true ) ) ; $ arg -> setKey ( $ key ) ; } $ values = $ arg -> getValues ( ) ; foreach ( $ values as $ index => $ val ) { if ( stripos ( $ val , PIPE_PH ) !== false ) { $ val = str_replace ( PIPE_PH , $ stdOut , $ val ) ; $ arg -> replaceValue ( $ index , $ val ) ; $ isXArg = true ; } } } } if ( ! $ isXArg ) { $ cmd -> setStdIn ( $ stdOut ) ; } } $ resultArray [ ] = $ result = $ cmd -> run ( ) ; } return $ resultArray ; }
Runs the command chain

@return \Tivie\Command\Result[]
@throws \Tivie\Command\Exception\Exception
@throws \Tivie\Command\Exception\InvalidArgumentException
Runs the command chain