示例#1
0
 /**
  * @return null
  */
 public function setUp()
 {
     $this->output = $this->getMock('Appfuel\\Kernel\\OutputInterface');
     $func = function ($data) {
         echo $data;
     };
     $this->output->expects($this->any())->method('renderError')->will($this->returnCallback($func));
     $this->handler = new FaultHandler($this->output);
 }
示例#2
0
 /**
  * Outputs a single or multiple error messages to stderr. If no parameters
  * are passed outputs just a newline.
  *
  * @param string|array $message A string or a an array of strings to output
  * @param integer $newlines Number of newlines to append
  * @return void
  * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::err
  */
 public function err($message = null, $newlines = 1)
 {
     $this->stderr->write($message, $newlines);
 }
示例#3
0
 /**
  * Implements writing to console.
  *
  * @param string $type The type of log you are making.
  * @param string $message The message you want to log.
  * @return boolean success of write.
  */
 public function write($type, $message)
 {
     $output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $message . "\n";
     return $this->_output->write(sprintf('<%s>%s</%s>', $type, $output, $type), false);
 }
示例#4
0
 /**
  * Prompts the user for input, and returns it.
  *
  * @param string $prompt Prompt text.
  * @param string|array $options Array or string of options.
  * @param string $default Default input value.
  *
  * @return Either the default value, or the user-provided input.
  */
 protected function _getInput($prompt, $options, $default)
 {
     if (!is_array($options)) {
         $printOptions = '';
     } else {
         $printOptions = '(' . implode('/', $options) . ')';
     }
     if ($default === null) {
         $this->stdout->write('<question>' . $prompt . '</question>' . " {$printOptions} \n" . '> ', 0);
     } else {
         $this->stdout->write('<question>' . $prompt . '</question>' . " {$printOptions} \n" . "[{$default}] > ", 0);
     }
     $result = $this->stdin->read();
     if ($result === false) {
         return $this->_stop(1);
     }
     $result = trim($result);
     if ($default !== null && ($result === '' || $result === null)) {
         return $default;
     }
     return $result;
 }
 function __destruct()
 {
     $this->console->resetAll();
 }
 /**
  * @param string $warningMessage
  */
 public function writeWarning($warningMessage)
 {
     $warningMessage = sprintf(" %s ", $warningMessage);
     parent::writeWarning($warningMessage);
 }