Beispiel #1
0
 /**
  * @param string   $line
  * @param string[] $block
  * @param int      $lineNumber
  */
 private function prepareCodeLine(string $line, array &$block, int $lineNumber)
 {
     $width = $this->cliWindowHelper->getWidth() - $this->gutterWidth;
     $line = str_replace("\t", '    ', $line);
     $gutter = str_pad($lineNumber, $this->gutterWidth - 1, ' ', STR_PAD_LEFT) . ' ';
     foreach (str_split($line, $width) as $lineChunk) {
         if (strlen($lineChunk) <= $width) {
             $block[] = '' . $this->colorizeGutter($gutter) . $this->colorizeLine(str_pad($lineChunk, $width, ' '));
         } else {
             $block[] = '' . $this->colorizeGutter($gutter) . $this->colorizeLine($lineChunk);
         }
         $gutter = str_repeat(' ', $this->gutterWidth);
     }
 }
Beispiel #2
0
 /**
  * Returns if colors should be enabled
  *
  * @return boolean
  */
 public function getEnableColoredOutput() : bool
 {
     return $this->enableColoredOutput && $this->cliWindowHelper->hasColorSupport();
 }