Example #1
0
 public function testGetMethods()
 {
     $style = new Style('BLACK', 'WHITE', array('BOLD' => true));
     $this->assertEquals('BLACK', $style->getForeground());
     $this->assertEquals('WHITE', $style->getBackground());
     $this->assertEquals(array('BOLD' => true), $style->getOptions());
 }
Example #2
0
 /**
  * Retrieves the ANSI string representation of requested color name
  *
  * @param Style $style Style
  * @return string
  */
 protected function _getBackgroundString(Style $style)
 {
     $background = $style->getBackground();
     if (empty($background)) {
         return '';
     }
     $esc = chr(27);
     switch (strtoupper($background)) {
         case 'BLACK':
             return $esc . '[40m';
         case 'RED':
             return $esc . '[41m';
         case 'GREEN':
             return $esc . '[42m';
         case 'YELLOW':
             return $esc . '[43m';
         case 'BLUE':
             return $esc . '[44m';
         case 'MAGENTA':
             return $esc . '[45m';
         case 'CYAN':
             return $esc . '[46m';
         case 'WHITE':
             return $esc . '[47m';
         case 'DEFAULT':
         default:
             return $esc . '[48m';
     }
 }