/**
  * Print a warning message if the condition evalutes to TRUE.
  *
  * @param boolean $condition
  * @param string  $message
  */
 public function warnIf($condition, $message = '')
 {
     $message = strlen($message) ? $message : 'Unknown Reason';
     if ($condition === true) {
         $this->outputWriter->write('    <warning>Warning during ' . $this->version->getExecutionState() . ': ' . $message . '</warning>');
     }
 }
Exemplo n.º 2
0
 private function summarizeStatistics()
 {
     foreach ($this->statistics as $key => $statistic) {
         $this->outputWriter->write(sprintf("\n     Collection %s\n", $key));
         $line = '     ';
         $line .= 'metric ' . str_repeat(' ', 16 - strlen('metric'));
         $line .= 'before ' . str_repeat(' ', 20 - strlen('before'));
         $line .= 'after ' . str_repeat(' ', 20 - strlen('after'));
         $line .= 'difference ' . str_repeat(' ', 20 - strlen('difference'));
         $this->outputWriter->write($line . "\n     " . str_repeat('=', 80));
         $before = $statistic->getBefore();
         $after = $statistic->getAfter();
         foreach (Statistics::$metrics as $metric) {
             $valueBefore = isset($before[$metric]) ? $before[$metric] : 0;
             $valueAfter = isset($after[$metric]) ? $after[$metric] : 0;
             $difference = $valueAfter - $valueBefore;
             $nameMessage = $metric . str_repeat(' ', 16 - strlen($metric));
             $beforeMessage = $valueBefore . str_repeat(' ', 20 - strlen($valueBefore));
             $afterMessage = $valueAfter . str_repeat(' ', 20 - strlen($valueAfter));
             $differenceMessage = $difference . str_repeat(' ', 20 - strlen($difference));
             $line = sprintf('     %s %s %s %s', $nameMessage, $beforeMessage, $afterMessage, $differenceMessage);
             $this->outputWriter->write($line);
         }
     }
 }