Since: 1.0
Author: Bernhard Schussek (bschussek@gmail.com)
Exemplo n.º 1
0
 /**
  * Calculates the text offset based on all labels in the alignment.
  *
  * The passed indentation is added to the indentations of all labeled
  * paragraphs.
  *
  * @param Formatter $formatter   The formatter used to remove style tags when
  *                               calculating the label width.
  * @param int       $indentation The indentation.
  */
 public function align(Formatter $formatter, $indentation = 0)
 {
     $this->textOffset = 0;
     foreach ($this->paragraphs as $i => $item) {
         $label = $formatter->removeFormat($item->getLabel());
         $textOffset = $this->indentations[$i] + strlen($label) + $item->getPadding();
         $this->textOffset = max($this->textOffset, $textOffset);
     }
     $this->textOffset += $indentation;
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function format($message)
 {
     if ($this->decorated) {
         return $this->adaptedFormatter->format($message);
     }
     return $this->adaptedFormatter->removeFormat($message);
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function removeFormat($string)
 {
     return $this->formatter->removeFormat($string);
 }
Exemplo n.º 4
0
 public static function getMaxLineLength($string, Formatter $formatter = null)
 {
     if ($formatter) {
         $string = $formatter->removeFormat($string);
     }
     $maxLength = 0;
     $lines = explode("\n", $string);
     foreach ($lines as $word) {
         // No need to pass the formatter because the tags are already
         // removed
         $maxLength = max($maxLength, self::getLength($word));
     }
     return $maxLength;
 }