コード例 #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
ファイル: Shell.php プロジェクト: 4Queen/php-buildpack
 /**
  * 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
ファイル: ConsoleLog.php プロジェクト: ophilli/Inventory
 /**
  * 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;
 }
コード例 #5
0
 function __destruct()
 {
     $this->console->resetAll();
 }
コード例 #6
0
 /**
  * @param string $warningMessage
  */
 public function writeWarning($warningMessage)
 {
     $warningMessage = sprintf(" %s ", $warningMessage);
     parent::writeWarning($warningMessage);
 }