Doctrine 1.2.4
Doctrine_Cli_Formatter Class Reference

Inherited by Doctrine_Cli_AnsiColorFormatter.

Public Member Functions

 __construct ($maxLineSize=65)
 
 excerpt ($text, $size=null)
 
 format ($text= '', $parameters=array(), $stream=STDOUT)
 
 formatSection ($section, $text, $size=null)
 
 setMaxLineSize ($size)
 

Detailed Description

Definition at line 43 of file Formatter.php.

Constructor & Destructor Documentation

Doctrine_Cli_Formatter::__construct (   $maxLineSize = 65)

__construct

Parameters
string$maxLineSize
Returns
void

Definition at line 53 of file Formatter.php.

{
$this->_size = $maxLineSize;
}

Member Function Documentation

Doctrine_Cli_Formatter::excerpt (   $text,
  $size = null 
)

Truncates a line.

Parameters
stringThe text
integerThe maximum size of the returned string (65 by default)
Returns
string The truncated string

Definition at line 92 of file Formatter.php.

{
if ( ! $size) {
$size = $this->_size;
}
if (strlen($text) < $size) {
return $text;
}
$subsize = floor(($size - 3) / 2);
return substr($text, 0, $subsize).'...'.substr($text, -$subsize);
}
Doctrine_Cli_Formatter::format (   $text = '',
  $parameters = array(),
  $stream = STDOUT 
)

Formats a text according to the given parameters.

Parameters
stringThe test to style
mixedAn array of parameters
streamA stream (default to STDOUT)
Returns
string The formatted text

Definition at line 67 of file Formatter.php.

{
return $text;
}
Doctrine_Cli_Formatter::formatSection (   $section,
  $text,
  $size = null 
)

Formats a message within a section.

Parameters
stringThe section name
stringThe text message
integerThe maximum size allowed for a line (65 by default)

Definition at line 79 of file Formatter.php.

{
return sprintf(">> %-$9s %s", $section, $this->excerpt($text, $size));
}
Doctrine_Cli_Formatter::setMaxLineSize (   $size)

Sets the maximum line size.

Parameters
integerThe maximum line size for a message

Definition at line 112 of file Formatter.php.

{
$this->_size = $size;
}

The documentation for this class was generated from the following file: