Example #1
0
 /**
  * Applies the style to a given text.
  *
  * @param string $text The text to style
  *
  * @return string
  */
 public function apply($text)
 {
     $ret = $text;
     // ##################
     // Padding
     // ##################
     if (!empty($this->padding)) {
         $ret = $this->padding . $ret;
     }
     // ##################
     // Wrap
     // ##################
     if (!empty($this->wrap)) {
         list($width) = $this->application->getTerminalDimensions();
         $length = strlen($text);
         $wrapLength = (int) ($width - $length - 2) / 2 * 0.5;
         if ($wrapLength >= 1) {
             $ret = str_repeat($this->wrap, $wrapLength) . ' ' . $ret . ' ' . str_repeat($this->wrap, $wrapLength);
         }
     }
     $ret = parent::apply($ret);
     // ##################
     // Padding
     // ##################
     if (!empty($this->paddingOutside)) {
         $ret = $this->paddingOutside . $ret;
     }
     return $ret;
 }