Esempio n. 1
0
 /**
  * Main Runner
  *
  * @param dynamic
  */
 protected function doRun()
 {
     $result = 0;
     $args = func_get_args();
     $host = $this->session->getHost();
     if (count($args) === 3) {
         list($method, $params, $retval) = $args;
         // Strip namespace
         $method = trim(str_replace(__NAMESPACE__, '', $method), '\\');
         $command = $method . ' => [' . implode(' , ', $params) . ']';
         $this->printOut('<comment>' . $host . '</comment> < <info>' . $command . '</info>');
         // Initial result evaluation
         $result = $retval;
         $halt = $result == false;
         // Prints process information
         // @codeCoverageIgnoreStart
         if ($halt) {
             $this->printOut('<error>Aborted</error>');
         } else {
             if (is_string($retval) || is_array($retval)) {
                 if (is_array($retval)) {
                     foreach ($retval as $key => $val) {
                         if (!is_numeric($key)) {
                             $resultDioArray[] = $key . ':' . $val;
                         }
                     }
                 } else {
                     $resultDioArray = array_filter(explode("\n", $retval));
                 }
                 foreach ($resultDioArray as $i => $resultDioLine) {
                     $this->printOut(($i === 0 ? '<comment>' . $host . '</comment>' : str_pad(' ', strlen($host))) . ' > <info>' . $resultDioLine . '</info>');
                 }
             } else {
                 $this->printOut('<comment>' . $host . '</comment> > <info>[OK]</info>');
             }
         }
         // @codeCoverageIgnoreEnd
     }
     return $result;
 }