123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- class sfFormatter
- {
- protected
- $size = 65;
- function __construct($maxLineSize = 65)
- {
- $this->size = $maxLineSize;
- }
-
- public function format($text = '', $parameters = array(), $stream = STDOUT)
- {
- return $text;
- }
-
- public function formatSection($section, $text, $size = null)
- {
- return sprintf(">> %-9s %s", $section, $this->excerpt($text, $size));
- }
-
- public function excerpt($text, $size = null)
- {
- if (!$size)
- {
- $size = $this->size;
- }
- if (strlen($text) < $size)
- {
- return $text;
- }
- $subsize = floor(($size - 3) / 2);
- return substr($text, 0, $subsize).'...'.substr($text, -$subsize);
- }
-
- public function setMaxLineSize($size)
- {
- $this->size = $size;
- }
- }
|