PHP Class Webmozart\Console\UI\Alignment\LabelAlignment

The alignment takes {@link LabeledParagraph} instances and aligns the texts next to the labels so that all texts start at the same offset. Pass the paragraphs that you want to align to {@link add()}. When you call {@link align()}, the text offset is calculated. You can retrieve the calculated offset with {@link getTextOffset()}.
Since: 1.0
Author: Bernhard Schussek ([email protected])
Afficher le fichier Open project: webmozart/console Class Usage Examples

Méthodes publiques

Méthode Description
add ( LabeledParagraph $paragraph, integer $indentation ) Adds a labeled paragraph to the alignment.
align ( Webmozart\Console\Api\Formatter\Formatter $formatter, integer $indentation ) Calculates the text offset based on all labels in the alignment.
getTextOffset ( ) : integer Returns the calculated text offset.
setTextOffset ( integer $textOffset ) Manually sets the text offset.

Method Details

add() public méthode

Adds a labeled paragraph to the alignment.
public add ( LabeledParagraph $paragraph, integer $indentation )
$paragraph Webmozart\Console\UI\Component\LabeledParagraph The labeled paragraph.
$indentation integer The indentation of the paragraph.

align() public méthode

The passed indentation is added to the indentations of all labeled paragraphs.
public align ( Webmozart\Console\Api\Formatter\Formatter $formatter, integer $indentation )
$formatter Webmozart\Console\Api\Formatter\Formatter The formatter used to remove style tags when calculating the label width.
$indentation integer The indentation.

getTextOffset() public méthode

Before calling {@link align()} or {@link setTextOffset()}, this method returns 0.
public getTextOffset ( ) : integer
Résultat integer The text offset.

setTextOffset() public méthode

Manually sets the text offset.
public setTextOffset ( integer $textOffset )
$textOffset integer The text offset.