PHP Класс Platformsh\Cli\Util\Table

Usage: In a command's configure() method, add the --format option: Table::addFormatOption($this->getDefinition()); In a command's execute() method, build and display the table: $table = new Table($input, $output); $header = ['Column 1', 'Column 2', 'Column 3']; $rows = [ ['Cell 1', 'Cell 2', 'Cell 3'], ['Cell 4', 'Cell 5', 'Cell 6'], ]; $table->render($rows, $header);
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$input
$output

Открытые методы

Метод Описание
__construct ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
addFormatOption ( Symfony\Component\Console\Input\InputDefinition $definition ) Add the --format option to a command's input definition.
formatIsMachineReadable ( ) : boolean Find whether the user wants machine-readable output.
render ( array $rows, array $header = [] ) Render a table of data to output.
renderSimple ( array $values, array $propertyNames ) Render an single-dimensional array of values, with their property names.

Защищенные методы

Метод Описание
getFormat ( ) : string | null Get the user-specified format.
renderCsv ( array $rows, array $header, string $delimiter = ',', string $enclosure = '"' ) Render CSV output.
renderTable ( array $rows, array $header ) Render a Symfony Console table.

Описание методов

__construct() публичный Метод

public __construct ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface

addFormatOption() публичный статический Метод

Add the --format option to a command's input definition.
public static addFormatOption ( Symfony\Component\Console\Input\InputDefinition $definition )
$definition Symfony\Component\Console\Input\InputDefinition

formatIsMachineReadable() публичный Метод

Find whether the user wants machine-readable output.
public formatIsMachineReadable ( ) : boolean
Результат boolean True if the user has specified a machine-readable format via the --format option (e.g. 'csv' or 'tsv'), false otherwise.

getFormat() защищенный Метод

Get the user-specified format.
protected getFormat ( ) : string | null
Результат string | null

render() публичный Метод

Render a table of data to output.
public render ( array $rows, array $header = [] )
$rows array The table rows.
$header array The table header (optional).

renderCsv() защищенный Метод

Render CSV output.
protected renderCsv ( array $rows, array $header, string $delimiter = ',', string $enclosure = '"' )
$rows array
$header array
$delimiter string
$enclosure string

renderSimple() публичный Метод

Render an single-dimensional array of values, with their property names.
public renderSimple ( array $values, array $propertyNames )
$values array
$propertyNames array

renderTable() защищенный Метод

Render a Symfony Console table.
protected renderTable ( array $rows, array $header )
$rows array
$header array

Описание свойств

$input защищенное свойство

protected $input

$output защищенное свойство

protected $output