Example #1
0
 /**
  * Loops through the row and sets the maximum width for each column.
  *
  * @param array $row The table row.
  *
  * @return array $row
  */
 protected function checkRow(array $row)
 {
     foreach ($row as $column => $str) {
         $width = strlen(Colors::decolorize($str));
         if (!isset($this->_width[$column]) || $width > $this->_width[$column]) {
             $this->_width[$column] = $width;
         }
     }
     return $row;
 }
Example #2
0
 /**
  * An encoding-safe way of padding string length for display
  *
  * @param string $string The string to pad
  * @param int    $length The length to pad it to
  *
  * @return string
  */
 public static function safeStrPad($string, $length)
 {
     // Hebrew vowel characters
     $cleaned_string = preg_replace('#[\\x{591}-\\x{5C7}]+#u', '', Colors::decolorize($string));
     if (function_exists('mb_strwidth') && function_exists('mb_detect_encoding')) {
         $real_length = mb_strwidth($cleaned_string, mb_detect_encoding($string));
     } else {
         $real_length = self::safeStrLen($cleaned_string);
     }
     $diff = strlen($string) - $real_length;
     $length += $diff;
     return str_pad($string, $length);
 }
Example #3
0
 private function padColumn($content, $column)
 {
     return $this->_characters['padding'] . Colors::pad($content, $this->_widths[$column]) . $this->_characters['padding'];
 }