Overview

Namespaces

  • Webmozart
    • Console
      • Adapter
      • Api
        • Application
        • Args
          • Format
        • Command
        • Config
        • Event
        • Formatter
        • IO
        • Resolver
      • Args
      • Config
      • Formatter
      • Handler
        • Help
      • IO
        • InputStream
        • OutputStream
      • Process
      • Resolver
      • UI
        • Alignment
        • Component
        • Help
        • Layout
        • Style
      • Util

Classes

  • LabelAlignment
  • Overview
  • Namespace
  • Class

Class LabelAlignment

Aligns labeled paragraphs.

The alignment takes Webmozart\Console\UI\Component\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 Webmozart\Console\UI\Alignment\LabelAlignment::add(). When you call Webmozart\Console\UI\Alignment\LabelAlignment::align(), the text offset is calculated. You can retrieve the calculated offset with Webmozart\Console\UI\Alignment\LabelAlignment::getTextOffset().

Namespace: Webmozart\Console\UI\Alignment
Author: Bernhard Schussek bschussek@gmail.com
Since: 1.0
Located at UI/Alignment/LabelAlignment.php
Methods summary
public
# add( Webmozart\Console\UI\Component\LabeledParagraph $paragraph, integer $indentation = 0 )

Adds a labeled paragraph to the alignment.

Adds a labeled paragraph to the alignment.

Parameters

$paragraph
The labeled paragraph.
$indentation
The indentation of the paragraph.
public
# align( Webmozart\Console\Api\Formatter\Formatter $formatter, integer $indentation = 0 )

Calculates the text offset based on all labels in the alignment.

Calculates the text offset based on all labels in the alignment.

The passed indentation is added to the indentations of all labeled paragraphs.

Parameters

$formatter

The formatter used to remove style tags when calculating the label width.

$indentation
The indentation.
public
# setTextOffset( integer $textOffset )

Manually sets the text offset.

Manually sets the text offset.

Parameters

$textOffset
The text offset.
public integer
# getTextOffset( )

Returns the calculated text offset.

Returns the calculated text offset.

Before calling Webmozart\Console\UI\Alignment\LabelAlignment::align() or Webmozart\Console\UI\Alignment\LabelAlignment::setTextOffset(), this method returns 0.

Returns

integer
The text offset.
Webmozart Console API API documentation generated by ApiGen