コード例 #1
0
ファイル: StyleTest.php プロジェクト: andreia/doctrine
 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());
 }
コード例 #2
0
ファイル: AnsiColorPrinter.php プロジェクト: andreia/doctrine
 /**
  * Retrieves the ANSI string representation of requested options
  *
  * @param Style $style Style
  * @return string
  */
 protected function _getOptionsString(Style $style)
 {
     $options = $style->getOptions();
     if (empty($options)) {
         return '';
     }
     $str = '';
     foreach ($options as $name => $value) {
         if ($value) {
             $name = strtoupper($name);
             switch ($name) {
                 case 'BOLD':
                     $str .= '1;';
                     break;
                 case 'HALF':
                     $str .= '2;';
                     break;
                 case 'UNDERLINE':
                     $str .= '4;';
                     break;
                 case 'BLINK':
                     $str .= '5;';
                     break;
                 case 'REVERSE':
                     $str .= '7;';
                     break;
                 case 'CONCEAL':
                     $str .= '8;';
                     break;
                 default:
                     // Ignore unknown option
                     break;
             }
         }
     }
     return $str;
 }