public function renderCell($cell, $width, $style)
 {
     $out = '';
     $out .= str_repeat($style->cellPaddingChar, $style->cellPadding);
     /*
     if ($this->backgroundColor || $this->foregroundColor) {
         $decoratedCell = Colors::decorate($cell, $this->foregroundColor, $this->backgroundColor);
         $width += mb_strlen($decoratedCell) - mb_strlen($cell);
         $cell = $decoratedCell;
     }
     */
     if ($this->alignment === CellAttribute::ALIGN_LEFT) {
         $out .= str_pad($cell, $width, ' ');
         // default alignment = LEFT
     } elseif ($this->alignment === CellAttribute::ALIGN_RIGHT) {
         $out .= str_pad($cell, $width, ' ', STR_PAD_LEFT);
     } elseif ($this->alignment === CellAttribute::ALIGN_CENTER) {
         $out .= str_pad($cell, $width, ' ', STR_PAD_BOTH);
     } else {
         $out .= str_pad($cell, $width, ' ');
         // default alignment
     }
     $out .= str_repeat($style->cellPaddingChar, $style->cellPadding);
     if ($this->backgroundColor || $this->foregroundColor) {
         return Colors::decorate($out, $this->foregroundColor, $this->backgroundColor);
     }
     return $out;
 }
Exemple #2
0
 /**
  * @dataProvider stringProvider
  */
 public function testStripAnsiEscapeCode($input, $fg, $bg)
 {
     $str = Colors::decorate($input, $fg, $bg);
     $output = Colors::stripAnsiEscapeCode($str);
     $this->assertEquals($input, $output);
 }