Add pear modules, mail and net_smtp via composer (#93)

Add pear modules, mail and net_smtp via composer, remove php 5.6 build due to phpunit 6
This commit is contained in:
Thilina Hasantha
2018-01-08 23:13:43 +01:00
committed by GitHub
parent 359e3f8382
commit e7792e7d79
2349 changed files with 117270 additions and 83170 deletions

View File

@@ -3,5 +3,4 @@
phpunit.xml
build
vendor
composer.lock
main.php

View File

@@ -6,11 +6,20 @@ branches:
- master
- /^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+.*$/
php:
- 7.0
- 5.6
- 5.5
- 5.4
matrix:
include:
-
php: 7.1
env: 'HIGHEST_LOWEST="update" STABILITY="RC"'
-
php: 7.0.11
-
php: 5.6
-
php: 5.5
-
php: 5.4
env: 'HIGHEST_LOWEST="update --prefer-lowest"'
sudo: false
@@ -20,7 +29,17 @@ cache:
- $HOME/.composer/cache
before_script:
- composer install
# If running a highest/lowest dependencies test, get rid of composer.lock
- |
if [ -n "$HIGHEST_LOWEST" ] ; then
rm composer.lock
composer config --unset platform.php
composer config minimum-stability ${STABILITY-stable}
fi
- 'composer -n ${HIGHEST_LOWEST-install} --prefer-dist'
- composer why symfony/console
# Print out all of the installed packages in alphabetical order, with versions
- composer licenses
script:
- vendor/bin/phpunit

View File

@@ -1,5 +1,52 @@
# Change Log
### 3.1.13 - 29 November 2017
- Allow XML output for RowsOfFields (#60).
- Allow Symfony 4 components and add make tests run on three versions of Symfony.
### 3.1.12 - 12 October 2017
- Bugfix: Use InputOption::VALUE_REQUIRED instead of InputOption::VALUE_OPTIONAL
for injected options such as --format and --fields.
- Bugfix: Ignore empty properties in the property parser.
### 3.1.11 - 17 August 2017
- Add ListDataFromKeys marker data type.
### 3.1.10 - 6 June 2017
- Typo in CalculateWidths::distributeLongColumns causes failure for some column width distributions
### 3.1.9 - 8 May 2017
- Improve wrapping algorithm
### 3.1.7 - 20 Jan 2017
- Add Windows testing
### 3.1.6 - 8 Jan 2017
- Move victorjonsson/markdowndocs to require-dev
### 3.1.5 - 23 November 2016
- When converting from XML to an array, use the 'id' or 'name' element as the array key value.
### 3.1.4 - 20 November 2016
- Add a 'list delimiter' formatter option, so that we can create a Drush-style table for property lists.
### 3.1.1 ~ 3.1.3 - 18 November 2016
- Fine-tune wordwrapping.
### 3.1.0 - 17 November 2016
- Add wordwrapping to table formatter.
### 3.0.0 - 14 November 2016
- **Breaking** The RenderCellInterface is now provided a reference to the entire row data. Existing clients need only add the new parameter to their method defnition to update.
@@ -9,10 +56,6 @@
### 2.1.0 - 7 November 2016
- Add RenderCellCollections to structured lists, so that commands may add renderers to structured data without defining a new structured data subclass.
### 2.0.1 - 4 October 2016
- Throw an exception if the client requests a field that does not exist.
- Remove unwanted extra layer of nesting when formatting an PropertyList with an array formatter (json, yaml, etc.).

View File

@@ -2,7 +2,11 @@
Apply transformations to structured data to write output in different formats.
[![Travis CI](https://travis-ci.org/consolidation/output-formatters.svg?branch=master)](https://travis-ci.org/consolidation/output-formatters) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/consolidation/output-formatters/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/consolidation/output-formatters/?branch=master) [![Coverage Status](https://coveralls.io/repos/github/consolidation/output-formatters/badge.svg?branch=master)](https://coveralls.io/github/consolidation/output-formatters?branch=master) [![License](https://poser.pugx.org/consolidation/output-formatters/license)](https://packagist.org/packages/consolidation/output-formatters)
[![Travis CI](https://travis-ci.org/consolidation/output-formatters.svg?branch=master)](https://travis-ci.org/consolidation/output-formatters)
[![Windows CI](https://ci.appveyor.com/api/projects/status/umyfuujca6d2g2k6?svg=true)](https://ci.appveyor.com/project/greg-1-anderson/output-formatters)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/consolidation/output-formatters/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/consolidation/output-formatters/?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/consolidation/output-formatters/badge.svg?branch=master)](https://coveralls.io/github/consolidation/output-formatters?branch=master)
[![License](https://poser.pugx.org/consolidation/output-formatters/license)](https://packagist.org/packages/consolidation/output-formatters)
## Component Status
@@ -50,6 +54,7 @@ Most formatters will operate on any array or ArrayObject data. Some formatters r
- `RowsOfFields`: Each row contains an associative array of field:value pairs. It is also assumed that the fields of each row are the same for every row. This format is ideal for displaying in a table, with labels in the top row.
- `PropertyList`: Each row contains a field:value pair. Each field is unique. This format is ideal for displaying in a table, with labels in the first column and values in the second common.
- `ListDataFromKeys`: The result may be structured or unstructured data. When formatted with the --format=list formatter, the result will come from the array keys instead of the array values.
- `DOMDocument`: The standard PHP DOM document class may be used by functions that need to be able to presicely specify the exact attributes and children when the XML output format is used.
Commands that return table structured data with fields can be filtered and/or re-ordered by using the --fields option. These structured data types can also be formatted into a more generic type such as yaml or json, even after being filtered. This capabilities are not available if the data is returned in a bare php array.

View File

@@ -0,0 +1,68 @@
build: false
shallow_clone: true
platform: 'x86'
clone_folder: C:\projects\output-formatters
branches:
only:
- master
## Cache composer bits
cache:
- '%LOCALAPPDATA%\Composer\files -> composer.lock'
init:
#https://github.com/composer/composer/blob/master/appveyor.yml
#- SET ANSICON=121x90 (121x90)
# Inspired by https://github.com/Codeception/base/blob/master/appveyor.yml and https://github.com/phpmd/phpmd/blob/master/appveyor.yml
install:
- cinst -y curl
- SET PATH=C:\Program Files\curl;%PATH%
#which is only needed by the test suite.
- cinst -y which
- SET PATH=C:\Program Files\which;%PATH%
- git clone -q https://github.com/acquia/DevDesktopCommon.git #For tar, cksum, ...
- SET PATH=%APPVEYOR_BUILD_FOLDER%/DevDesktopCommon/bintools-win/msys/bin;%PATH%
- SET PATH=C:\Program Files\MySql\MySQL Server 5.7\bin\;%PATH%
#Install PHP per https://blog.wyrihaximus.net/2016/11/running-php-unit-tests-on-windows-using-appveyor-and-chocolatey/
- ps: appveyor-retry cinst --ignore-checksums -y php --version ((choco search php --exact --all-versions -r | select-string -pattern $Env:php_ver_target | Select-Object -first 1) -replace '[php|]','')
- cd c:\tools\php70
- copy php.ini-production php.ini
- echo extension_dir=ext >> php.ini
- echo extension=php_openssl.dll >> php.ini
- echo date.timezone="UTC" >> php.ini
- echo variables_order="EGPCS" >> php.ini #May be unneeded.
- echo mbstring.http_input=pass >> php.ini
- echo mbstring.http_output=pass >> php.ini
- echo sendmail_path=nul >> php.ini
- echo extension=php_mbstring.dll >> php.ini
- echo extension=php_curl.dll >> php.ini
- echo extension=php_pdo_mysql.dll >> php.ini
- echo extension=php_pdo_pgsql.dll >> php.ini
- echo extension=php_pdo_sqlite.dll >> php.ini
- echo extension=php_pgsql.dll >> php.ini
- echo extension=php_gd2.dll >> php.ini
- SET PATH=C:\tools\php70;%PATH%
#Install Composer
- cd %APPVEYOR_BUILD_FOLDER%
#- appveyor DownloadFile https://getcomposer.org/composer.phar
- php -r "readfile('http://getcomposer.org/installer');" | php
#Install dependencies via Composer.
#Newer versions of the dependencies have whitespace differences that break tests.
#Maybe we should fix and do highest/lowest here someday.
- copy composer.windows.lock composer.lock
- php composer.phar -q install --prefer-dist -n
- SET PATH=%APPVEYOR_BUILD_FOLDER%;%APPVEYOR_BUILD_FOLDER%/vendor/bin;%PATH%
#Create a sandbox for testing. Don't think we need this.
- mkdir c:\test_temp
test_script:
- php composer.phar test
- php composer.phar cs
# environment variables
environment:
global:
php_ver_target: 7.0

View File

@@ -20,14 +20,14 @@
},
"require": {
"php": ">=5.4.0",
"symfony/console": "~2.5|~3.0",
"symfony/finder": "~2.5|~3.0",
"victorjonsson/markdowndocs": "^1.3"
"symfony/console": "^2.8|^3|^4",
"symfony/finder": "^2.5|^3|^4"
},
"require-dev": {
"phpunit/phpunit": "4.*",
"satooshi/php-coveralls": "^1.0",
"squizlabs/php_codesniffer": "2.*"
"phpunit/phpunit": "^4.8",
"satooshi/php-coveralls": "^1.0.2 | dev-master",
"squizlabs/php_codesniffer": "^2.7",
"victorjonsson/markdowndocs": "^1.3"
},
"scripts": {
"api": "phpdoc-md generate src > docs/api.md",
@@ -37,7 +37,12 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
"dev-master": "3.x-dev"
}
},
"config": {
"platform": {
"php": "5.6"
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,53 +1,58 @@
## Table of contents
- [\Consolidation\OutputFormatters\FormatterManager](#class-consolidationoutputformattersformattermanager)
- [\Consolidation\OutputFormatters\Exception\UnknownFormatException](#class-consolidationoutputformattersexceptionunknownformatexception)
- [\Consolidation\OutputFormatters\Exception\AbstractDataFormatException (abstract)](#class-consolidationoutputformattersexceptionabstractdataformatexception-abstract)
- [\Consolidation\OutputFormatters\Exception\IncompatibleDataException](#class-consolidationoutputformattersexceptionincompatibledataexception)
- [\Consolidation\OutputFormatters\Exception\InvalidFormatException](#class-consolidationoutputformattersexceptioninvalidformatexception)
- [\Consolidation\OutputFormatters\Exception\UnknownFieldException](#class-consolidationoutputformattersexceptionunknownfieldexception)
- [\Consolidation\OutputFormatters\Exception\UnknownFormatException](#class-consolidationoutputformattersexceptionunknownformatexception)
- [\Consolidation\OutputFormatters\Formatters\CsvFormatter](#class-consolidationoutputformattersformatterscsvformatter)
- [\Consolidation\OutputFormatters\Formatters\FormatterInterface (interface)](#interface-consolidationoutputformattersformattersformatterinterface)
- [\Consolidation\OutputFormatters\Formatters\JsonFormatter](#class-consolidationoutputformattersformattersjsonformatter)
- [\Consolidation\OutputFormatters\Formatters\ListFormatter](#class-consolidationoutputformattersformatterslistformatter)
- [\Consolidation\OutputFormatters\Formatters\PrintRFormatter](#class-consolidationoutputformattersformattersprintrformatter)
- [\Consolidation\OutputFormatters\Formatters\RenderDataInterface (interface)](#interface-consolidationoutputformattersformattersrenderdatainterface)
- [\Consolidation\OutputFormatters\Formatters\SectionsFormatter](#class-consolidationoutputformattersformatterssectionsformatter)
- [\Consolidation\OutputFormatters\Formatters\JsonFormatter](#class-consolidationoutputformattersformattersjsonformatter)
- [\Consolidation\OutputFormatters\Formatters\FormatterInterface (interface)](#interface-consolidationoutputformattersformattersformatterinterface)
- [\Consolidation\OutputFormatters\Formatters\CsvFormatter](#class-consolidationoutputformattersformatterscsvformatter)
- [\Consolidation\OutputFormatters\Formatters\SerializeFormatter](#class-consolidationoutputformattersformattersserializeformatter)
- [\Consolidation\OutputFormatters\Formatters\StringFormatter](#class-consolidationoutputformattersformattersstringformatter)
- [\Consolidation\OutputFormatters\Formatters\TableFormatter](#class-consolidationoutputformattersformatterstableformatter)
- [\Consolidation\OutputFormatters\Formatters\TsvFormatter](#class-consolidationoutputformattersformatterstsvformatter)
- [\Consolidation\OutputFormatters\Formatters\VarExportFormatter](#class-consolidationoutputformattersformattersvarexportformatter)
- [\Consolidation\OutputFormatters\Formatters\XmlFormatter](#class-consolidationoutputformattersformattersxmlformatter)
- [\Consolidation\OutputFormatters\Formatters\YamlFormatter](#class-consolidationoutputformattersformattersyamlformatter)
- [\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)
- [\Consolidation\OutputFormatters\Formatters\TableFormatter](#class-consolidationoutputformattersformatterstableformatter)
- [\Consolidation\OutputFormatters\Formatters\XmlFormatter](#class-consolidationoutputformattersformattersxmlformatter)
- [\Consolidation\OutputFormatters\Formatters\PrintRFormatter](#class-consolidationoutputformattersformattersprintrformatter)
- [\Consolidation\OutputFormatters\Formatters\RenderDataInterface (interface)](#interface-consolidationoutputformattersformattersrenderdatainterface)
- [\Consolidation\OutputFormatters\Formatters\TsvFormatter](#class-consolidationoutputformattersformatterstsvformatter)
- [\Consolidation\OutputFormatters\Options\OverrideOptionsInterface (interface)](#interface-consolidationoutputformattersoptionsoverrideoptionsinterface)
- [\Consolidation\OutputFormatters\StructuredData\AbstractStructuredList (abstract)](#class-consolidationoutputformattersstructureddataabstractstructuredlist-abstract)
- [\Consolidation\OutputFormatters\StructuredData\AssociativeList](#class-consolidationoutputformattersstructureddataassociativelist)
- [\Consolidation\OutputFormatters\StructuredData\CallableRenderer](#class-consolidationoutputformattersstructureddatacallablerenderer)
- [\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)
- [\Consolidation\OutputFormatters\StructuredData\ListDataInterface (interface)](#interface-consolidationoutputformattersstructureddatalistdatainterface)
- [\Consolidation\OutputFormatters\StructuredData\OriginalDataInterface (interface)](#interface-consolidationoutputformattersstructureddataoriginaldatainterface)
- [\Consolidation\OutputFormatters\StructuredData\PropertyList](#class-consolidationoutputformattersstructureddatapropertylist)
- [\Consolidation\OutputFormatters\StructuredData\RenderCellCollectionInterface (interface)](#interface-consolidationoutputformattersstructureddatarendercellcollectioninterface)
- [\Consolidation\OutputFormatters\StructuredData\RenderCellInterface (interface)](#interface-consolidationoutputformattersstructureddatarendercellinterface)
- [\Consolidation\OutputFormatters\StructuredData\RestructureInterface (interface)](#interface-consolidationoutputformattersstructureddatarestructureinterface)
- [\Consolidation\OutputFormatters\StructuredData\RowsOfFields](#class-consolidationoutputformattersstructureddatarowsoffields)
- [\Consolidation\OutputFormatters\StructuredData\TableDataInterface (interface)](#interface-consolidationoutputformattersstructureddatatabledatainterface)
- [\Consolidation\OutputFormatters\StructuredData\HelpDocument](#class-consolidationoutputformattersstructureddatahelpdocument)
- [\Consolidation\OutputFormatters\StructuredData\OriginalDataInterface (interface)](#interface-consolidationoutputformattersstructureddataoriginaldatainterface)
- [\Consolidation\OutputFormatters\StructuredData\RowsOfFields](#class-consolidationoutputformattersstructureddatarowsoffields)
- [\Consolidation\OutputFormatters\StructuredData\RestructureInterface (interface)](#interface-consolidationoutputformattersstructureddatarestructureinterface)
- [\Consolidation\OutputFormatters\StructuredData\AbstractStructuredList (abstract)](#class-consolidationoutputformattersstructureddataabstractstructuredlist-abstract)
- [\Consolidation\OutputFormatters\StructuredData\ListDataFromKeys](#class-consolidationoutputformattersstructureddatalistdatafromkeys)
- [\Consolidation\OutputFormatters\StructuredData\PropertyList](#class-consolidationoutputformattersstructureddatapropertylist)
- [\Consolidation\OutputFormatters\StructuredData\RenderCellInterface (interface)](#interface-consolidationoutputformattersstructureddatarendercellinterface)
- [\Consolidation\OutputFormatters\StructuredData\CallableRenderer](#class-consolidationoutputformattersstructureddatacallablerenderer)
- [\Consolidation\OutputFormatters\StructuredData\RenderCellCollectionInterface (interface)](#interface-consolidationoutputformattersstructureddatarendercellcollectioninterface)
- [\Consolidation\OutputFormatters\StructuredData\AssociativeList](#class-consolidationoutputformattersstructureddataassociativelist)
- [\Consolidation\OutputFormatters\StructuredData\Xml\XmlSchemaInterface (interface)](#interface-consolidationoutputformattersstructureddataxmlxmlschemainterface)
- [\Consolidation\OutputFormatters\StructuredData\Xml\DomDataInterface (interface)](#interface-consolidationoutputformattersstructureddataxmldomdatainterface)
- [\Consolidation\OutputFormatters\StructuredData\Xml\XmlSchema](#class-consolidationoutputformattersstructureddataxmlxmlschema)
- [\Consolidation\OutputFormatters\StructuredData\Xml\XmlSchemaInterface (interface)](#interface-consolidationoutputformattersstructureddataxmlxmlschemainterface)
- [\Consolidation\OutputFormatters\Transformations\DomToArraySimplifier](#class-consolidationoutputformatterstransformationsdomtoarraysimplifier)
- [\Consolidation\OutputFormatters\Transformations\OverrideRestructureInterface (interface)](#interface-consolidationoutputformatterstransformationsoverriderestructureinterface)
- [\Consolidation\OutputFormatters\Transformations\PropertyListTableTransformation](#class-consolidationoutputformatterstransformationspropertylisttabletransformation)
- [\Consolidation\OutputFormatters\Transformations\PropertyParser](#class-consolidationoutputformatterstransformationspropertyparser)
- [\Consolidation\OutputFormatters\Transformations\ReorderFields](#class-consolidationoutputformatterstransformationsreorderfields)
- [\Consolidation\OutputFormatters\Transformations\SimplifyToArrayInterface (interface)](#interface-consolidationoutputformatterstransformationssimplifytoarrayinterface)
- [\Consolidation\OutputFormatters\Transformations\PropertyListTableTransformation](#class-consolidationoutputformatterstransformationspropertylisttabletransformation)
- [\Consolidation\OutputFormatters\Transformations\TableTransformation](#class-consolidationoutputformatterstransformationstabletransformation)
- [\Consolidation\OutputFormatters\Transformations\ReorderFields](#class-consolidationoutputformatterstransformationsreorderfields)
- [\Consolidation\OutputFormatters\Transformations\DomToArraySimplifier](#class-consolidationoutputformatterstransformationsdomtoarraysimplifier)
- [\Consolidation\OutputFormatters\Transformations\WordWrapper](#class-consolidationoutputformatterstransformationswordwrapper)
- [\Consolidation\OutputFormatters\Transformations\OverrideRestructureInterface (interface)](#interface-consolidationoutputformatterstransformationsoverriderestructureinterface)
- [\Consolidation\OutputFormatters\Transformations\SimplifyToArrayInterface (interface)](#interface-consolidationoutputformatterstransformationssimplifytoarrayinterface)
- [\Consolidation\OutputFormatters\Transformations\Wrap\CalculateWidths](#class-consolidationoutputformatterstransformationswrapcalculatewidths)
- [\Consolidation\OutputFormatters\Transformations\Wrap\ColumnWidths](#class-consolidationoutputformatterstransformationswrapcolumnwidths)
- [\Consolidation\OutputFormatters\Validate\ValidationInterface (interface)](#interface-consolidationoutputformattersvalidatevalidationinterface)
- [\Consolidation\OutputFormatters\Validate\ValidDataTypesInterface (interface)](#interface-consolidationoutputformattersvalidatevaliddatatypesinterface)
<hr />
<hr />
### Class: \Consolidation\OutputFormatters\FormatterManager
> Manage a collection of formatters; return one on request.
@@ -76,7 +81,22 @@
| protected | <strong>simplifyToArray(</strong><em>mixed</em> <strong>$structuredOutput</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>void</em> |
| protected | <strong>validateAndRestructure(</strong><em>[\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface)</em> <strong>$formatter</strong>, <em>mixed</em> <strong>$structuredOutput</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>void</em> |
<hr />
<hr />
### Class: \Consolidation\OutputFormatters\Exception\UnknownFormatException
> Indicates that the requested format does not exist.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>__construct(</strong><em>mixed</em> <strong>$format</strong>)</strong> : <em>void</em> |
*This class extends \Exception*
*This class implements \Throwable*
<hr />
### Class: \Consolidation\OutputFormatters\Exception\AbstractDataFormatException (abstract)
> Contains some helper functions used by exceptions in this project.
@@ -91,7 +111,8 @@
*This class implements \Throwable*
<hr />
<hr />
### Class: \Consolidation\OutputFormatters\Exception\IncompatibleDataException
> Represents an incompatibility between the output data and selected formatter.
@@ -104,7 +125,8 @@
*This class implements \Throwable*
<hr />
<hr />
### Class: \Consolidation\OutputFormatters\Exception\InvalidFormatException
> Represents an incompatibility between the output data and selected formatter.
@@ -117,7 +139,8 @@
*This class implements \Throwable*
<hr />
<hr />
### Class: \Consolidation\OutputFormatters\Exception\UnknownFieldException
> Indicates that the requested format does not exist.
@@ -130,20 +153,60 @@
*This class implements \Throwable*
<hr />
### Class: \Consolidation\OutputFormatters\Exception\UnknownFormatException
<hr />
> Indicates that the requested format does not exist.
### Class: \Consolidation\OutputFormatters\Formatters\ListFormatter
> Display the data in a simple list. This formatter prints a plain, unadorned list of data, with each data item appearing on a separate line. If you wish your list to contain headers, then use the table formatter, and wrap your data in an PropertyList.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>__construct(</strong><em>mixed</em> <strong>$format</strong>)</strong> : <em>void</em> |
| public | <strong>overrideRestructure(</strong><em>mixed</em> <strong>$structuredOutput</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>mixed</em><br /><em>Select data to use directly from the structured output, before the restructure operation has been executed.</em> |
| public | <strong>renderData(</strong><em>mixed</em> <strong>$originalData</strong>, <em>mixed</em> <strong>$restructuredData</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>mixed</em><br /><em>Convert the contents of the output data just before it is to be printed, prior to output but after restructuring and validation.</em> |
| public | <strong>write(</strong><em>\Symfony\Component\Console\Output\OutputInterface</em> <strong>$output</strong>, <em>mixed</em> <strong>$data</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>string</em><br /><em>Given structured data, apply appropriate formatting, and return a printable string.</em> |
| protected | <strong>renderEachCell(</strong><em>mixed</em> <strong>$originalData</strong>, <em>mixed</em> <strong>$restructuredData</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>void</em> |
*This class extends \Exception*
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface), [\Consolidation\OutputFormatters\Transformations\OverrideRestructureInterface](#interface-consolidationoutputformatterstransformationsoverriderestructureinterface), [\Consolidation\OutputFormatters\Formatters\RenderDataInterface](#interface-consolidationoutputformattersformattersrenderdatainterface)*
*This class implements \Throwable*
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\SectionsFormatter
> Display sections of data. This formatter takes data in the RowsOfFields data type. Each row represents one section; the data in each section is rendered in two columns, with the key in the first column and the value in the second column.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>isValidDataType(</strong><em>[\ReflectionClass](http://php.net/manual/en/class.reflectionclass.php)</em> <strong>$dataType</strong>)</strong> : <em>bool</em><br /><em>Return the list of data types acceptable to this formatter</em> |
| public | <strong>renderData(</strong><em>mixed</em> <strong>$originalData</strong>, <em>mixed</em> <strong>$restructuredData</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>mixed</em><br /><em>Convert the contents of the output data just before it is to be printed, prior to output but after restructuring and validation.</em> |
| public | <strong>validDataTypes()</strong> : <em>void</em> |
| public | <strong>validate(</strong><em>mixed</em> <strong>$structuredData</strong>)</strong> : <em>mixed</em><br /><em>Throw an IncompatibleDataException if the provided data cannot be processed by this formatter. Return the source data if it is valid. The data may be encapsulated or converted if necessary.</em> |
| public | <strong>write(</strong><em>\Symfony\Component\Console\Output\OutputInterface</em> <strong>$output</strong>, <em>mixed</em> <strong>$data</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>string</em><br /><em>Given structured data, apply appropriate formatting, and return a printable string.</em> |
| protected | <strong>renderEachCell(</strong><em>mixed</em> <strong>$originalData</strong>, <em>mixed</em> <strong>$restructuredData</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>void</em> |
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface), [\Consolidation\OutputFormatters\Validate\ValidDataTypesInterface](#interface-consolidationoutputformattersvalidatevaliddatatypesinterface), [\Consolidation\OutputFormatters\Validate\ValidationInterface](#interface-consolidationoutputformattersvalidatevalidationinterface), [\Consolidation\OutputFormatters\Formatters\RenderDataInterface](#interface-consolidationoutputformattersformattersrenderdatainterface)*
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\JsonFormatter
> Json formatter Convert an array or ArrayObject into Json.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>write(</strong><em>\Symfony\Component\Console\Output\OutputInterface</em> <strong>$output</strong>, <em>mixed</em> <strong>$data</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>string</em><br /><em>Given structured data, apply appropriate formatting, and return a printable string.</em> |
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface)*
<hr />
### Interface: \Consolidation\OutputFormatters\Formatters\FormatterInterface
| Visibility | Function |
|:-----------|:---------|
| public | <strong>write(</strong><em>\Symfony\Component\Console\Output\OutputInterface</em> <strong>$output</strong>, <em>mixed</em> <strong>$data</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>string</em><br /><em>Given structured data, apply appropriate formatting, and return a printable string.</em> |
<hr />
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\CsvFormatter
> Comma-separated value formatters Display the provided structured data in a comma-separated list. If there are multiple records provided, then they will be printed one per line. The primary data types accepted are RowsOfFields and PropertyList. The later behaves exactly like the former, save for the fact that it contains but a single row. This formmatter can also accept a PHP array; this is also interpreted as a single-row of data with no header.
@@ -162,73 +225,8 @@
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface), [\Consolidation\OutputFormatters\Validate\ValidDataTypesInterface](#interface-consolidationoutputformattersvalidatevaliddatatypesinterface), [\Consolidation\OutputFormatters\Validate\ValidationInterface](#interface-consolidationoutputformattersvalidatevalidationinterface), [\Consolidation\OutputFormatters\Formatters\RenderDataInterface](#interface-consolidationoutputformattersformattersrenderdatainterface)*
<hr />
### Interface: \Consolidation\OutputFormatters\Formatters\FormatterInterface
<hr />
| Visibility | Function |
|:-----------|:---------|
| public | <strong>write(</strong><em>\Symfony\Component\Console\Output\OutputInterface</em> <strong>$output</strong>, <em>mixed</em> <strong>$data</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>string</em><br /><em>Given structured data, apply appropriate formatting, and return a printable string.</em> |
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\JsonFormatter
> Json formatter Convert an array or ArrayObject into Json.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>write(</strong><em>\Symfony\Component\Console\Output\OutputInterface</em> <strong>$output</strong>, <em>mixed</em> <strong>$data</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>string</em><br /><em>Given structured data, apply appropriate formatting, and return a printable string.</em> |
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface)*
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\ListFormatter
> Display the data in a simple list. This formatter prints a plain, unadorned list of data, with each data item appearing on a separate line. If you wish your list to contain headers, then use the table formatter, and wrap your data in an PropertyList.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>overrideRestructure(</strong><em>mixed</em> <strong>$structuredOutput</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>mixed</em><br /><em>Select data to use directly from the structured output, before the restructure operation has been executed.</em> |
| public | <strong>renderData(</strong><em>mixed</em> <strong>$originalData</strong>, <em>mixed</em> <strong>$restructuredData</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>mixed</em><br /><em>Convert the contents of the output data just before it is to be printed, prior to output but after restructuring and validation.</em> |
| public | <strong>write(</strong><em>\Symfony\Component\Console\Output\OutputInterface</em> <strong>$output</strong>, <em>mixed</em> <strong>$data</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>string</em><br /><em>Given structured data, apply appropriate formatting, and return a printable string.</em> |
| protected | <strong>renderEachCell(</strong><em>mixed</em> <strong>$originalData</strong>, <em>mixed</em> <strong>$restructuredData</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>void</em> |
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface), [\Consolidation\OutputFormatters\Transformations\OverrideRestructureInterface](#interface-consolidationoutputformatterstransformationsoverriderestructureinterface), [\Consolidation\OutputFormatters\Formatters\RenderDataInterface](#interface-consolidationoutputformattersformattersrenderdatainterface)*
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\PrintRFormatter
> Print_r formatter Run provided date thruogh print_r.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>write(</strong><em>\Symfony\Component\Console\Output\OutputInterface</em> <strong>$output</strong>, <em>mixed</em> <strong>$data</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>string</em><br /><em>Given structured data, apply appropriate formatting, and return a printable string.</em> |
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface)*
<hr />
### Interface: \Consolidation\OutputFormatters\Formatters\RenderDataInterface
| Visibility | Function |
|:-----------|:---------|
| public | <strong>renderData(</strong><em>mixed</em> <strong>$originalData</strong>, <em>mixed</em> <strong>$restructuredData</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>mixed</em><br /><em>Convert the contents of the output data just before it is to be printed, prior to output but after restructuring and validation.</em> |
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\SectionsFormatter
> Display sections of data. This formatter takes data in the RowsOfFields data type. Each row represents one section; the data in each section is rendered in two columns, with the key in the first column and the value in the second column.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>isValidDataType(</strong><em>[\ReflectionClass](http://php.net/manual/en/class.reflectionclass.php)</em> <strong>$dataType</strong>)</strong> : <em>bool</em><br /><em>Return the list of data types acceptable to this formatter</em> |
| public | <strong>renderData(</strong><em>mixed</em> <strong>$originalData</strong>, <em>mixed</em> <strong>$restructuredData</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>mixed</em><br /><em>Convert the contents of the output data just before it is to be printed, prior to output but after restructuring and validation.</em> |
| public | <strong>validDataTypes()</strong> : <em>void</em> |
| public | <strong>validate(</strong><em>mixed</em> <strong>$structuredData</strong>)</strong> : <em>mixed</em><br /><em>Throw an IncompatibleDataException if the provided data cannot be processed by this formatter. Return the source data if it is valid. The data may be encapsulated or converted if necessary.</em> |
| public | <strong>write(</strong><em>\Symfony\Component\Console\Output\OutputInterface</em> <strong>$output</strong>, <em>mixed</em> <strong>$data</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>string</em><br /><em>Given structured data, apply appropriate formatting, and return a printable string.</em> |
| protected | <strong>renderEachCell(</strong><em>mixed</em> <strong>$originalData</strong>, <em>mixed</em> <strong>$restructuredData</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>void</em> |
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface), [\Consolidation\OutputFormatters\Validate\ValidDataTypesInterface](#interface-consolidationoutputformattersvalidatevaliddatatypesinterface), [\Consolidation\OutputFormatters\Validate\ValidationInterface](#interface-consolidationoutputformattersvalidatevalidationinterface), [\Consolidation\OutputFormatters\Formatters\RenderDataInterface](#interface-consolidationoutputformattersformattersrenderdatainterface)*
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\SerializeFormatter
> Serialize formatter Run provided date thruogh serialize.
@@ -239,7 +237,8 @@
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface)*
<hr />
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\StringFormatter
> String formatter This formatter is used as the default action when no particular formatter is requested. It will print the provided data only if it is a string; if any other type is given, then nothing is printed.
@@ -254,7 +253,32 @@
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface), [\Consolidation\OutputFormatters\Validate\ValidationInterface](#interface-consolidationoutputformattersvalidatevalidationinterface), [\Consolidation\OutputFormatters\Options\OverrideOptionsInterface](#interface-consolidationoutputformattersoptionsoverrideoptionsinterface)*
<hr />
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\VarExportFormatter
> Var_export formatter Run provided date thruogh var_export.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>write(</strong><em>\Symfony\Component\Console\Output\OutputInterface</em> <strong>$output</strong>, <em>mixed</em> <strong>$data</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>string</em><br /><em>Given structured data, apply appropriate formatting, and return a printable string.</em> |
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface)*
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\YamlFormatter
> Yaml formatter Convert an array or ArrayObject into Yaml.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>write(</strong><em>\Symfony\Component\Console\Output\OutputInterface</em> <strong>$output</strong>, <em>mixed</em> <strong>$data</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>string</em><br /><em>Given structured data, apply appropriate formatting, and return a printable string.</em> |
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface)*
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\TableFormatter
> Display a table of data with the Symfony Table class. This formatter takes data of either the RowsOfFields or PropertyList data type. Tables can be rendered with the rows running either vertically (the normal orientation) or horizontally. By default, associative lists will be displayed as two columns, with the key in the first column and the value in the second column.
@@ -273,7 +297,44 @@
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface), [\Consolidation\OutputFormatters\Validate\ValidDataTypesInterface](#interface-consolidationoutputformattersvalidatevaliddatatypesinterface), [\Consolidation\OutputFormatters\Validate\ValidationInterface](#interface-consolidationoutputformattersvalidatevalidationinterface), [\Consolidation\OutputFormatters\Formatters\RenderDataInterface](#interface-consolidationoutputformattersformattersrenderdatainterface)*
<hr />
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\XmlFormatter
> Display a table of data with the Symfony Table class. This formatter takes data of either the RowsOfFields or PropertyList data type. Tables can be rendered with the rows running either vertically (the normal orientation) or horizontally. By default, associative lists will be displayed as two columns, with the key in the first column and the value in the second column.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>__construct()</strong> : <em>void</em> |
| public | <strong>isValidDataType(</strong><em>[\ReflectionClass](http://php.net/manual/en/class.reflectionclass.php)</em> <strong>$dataType</strong>)</strong> : <em>bool</em><br /><em>Return the list of data types acceptable to this formatter</em> |
| public | <strong>validDataTypes()</strong> : <em>void</em> |
| public | <strong>validate(</strong><em>mixed</em> <strong>$structuredData</strong>)</strong> : <em>mixed</em><br /><em>Throw an IncompatibleDataException if the provided data cannot be processed by this formatter. Return the source data if it is valid. The data may be encapsulated or converted if necessary.</em> |
| public | <strong>write(</strong><em>\Symfony\Component\Console\Output\OutputInterface</em> <strong>$output</strong>, <em>mixed</em> <strong>$data</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>string</em><br /><em>Given structured data, apply appropriate formatting, and return a printable string.</em> |
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface), [\Consolidation\OutputFormatters\Validate\ValidDataTypesInterface](#interface-consolidationoutputformattersvalidatevaliddatatypesinterface), [\Consolidation\OutputFormatters\Validate\ValidationInterface](#interface-consolidationoutputformattersvalidatevalidationinterface)*
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\PrintRFormatter
> Print_r formatter Run provided date thruogh print_r.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>write(</strong><em>\Symfony\Component\Console\Output\OutputInterface</em> <strong>$output</strong>, <em>mixed</em> <strong>$data</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>string</em><br /><em>Given structured data, apply appropriate formatting, and return a printable string.</em> |
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface)*
<hr />
### Interface: \Consolidation\OutputFormatters\Formatters\RenderDataInterface
| Visibility | Function |
|:-----------|:---------|
| public | <strong>renderData(</strong><em>mixed</em> <strong>$originalData</strong>, <em>mixed</em> <strong>$restructuredData</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>mixed</em><br /><em>Convert the contents of the output data just before it is to be printed, prior to output but after restructuring and validation.</em> |
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\TsvFormatter
> Tab-separated value formatters Display the provided structured data in a tab-separated list. Output escaping is much lighter, since there is no allowance for altering the delimiter.
@@ -290,44 +351,16 @@
*This class implements [\Consolidation\OutputFormatters\Formatters\RenderDataInterface](#interface-consolidationoutputformattersformattersrenderdatainterface), [\Consolidation\OutputFormatters\Validate\ValidationInterface](#interface-consolidationoutputformattersvalidatevalidationinterface), [\Consolidation\OutputFormatters\Validate\ValidDataTypesInterface](#interface-consolidationoutputformattersvalidatevaliddatatypesinterface), [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface)*
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\VarExportFormatter
<hr />
> Var_export formatter Run provided date thruogh var_export.
### Interface: \Consolidation\OutputFormatters\Options\OverrideOptionsInterface
| Visibility | Function |
|:-----------|:---------|
| public | <strong>write(</strong><em>\Symfony\Component\Console\Output\OutputInterface</em> <strong>$output</strong>, <em>mixed</em> <strong>$data</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>string</em><br /><em>Given structured data, apply appropriate formatting, and return a printable string.</em> |
| public | <strong>overrideOptions(</strong><em>mixed</em> <strong>$structuredOutput</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em><br /><em>Allow the formatter to mess with the configuration options before any transformations et. al. get underway.</em> |
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface)*
<hr />
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\XmlFormatter
> Display a table of data with the Symfony Table class. This formatter takes data of either the RowsOfFields or PropertyList data type. Tables can be rendered with the rows running either vertically (the normal orientation) or horizontally. By default, associative lists will be displayed as two columns, with the key in the first column and the value in the second column.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>__construct()</strong> : <em>void</em> |
| public | <strong>isValidDataType(</strong><em>[\ReflectionClass](http://php.net/manual/en/class.reflectionclass.php)</em> <strong>$dataType</strong>)</strong> : <em>bool</em><br /><em>Return the list of data types acceptable to this formatter</em> |
| public | <strong>validDataTypes()</strong> : <em>void</em> |
| public | <strong>validate(</strong><em>mixed</em> <strong>$structuredData</strong>)</strong> : <em>mixed</em><br /><em>Throw an IncompatibleDataException if the provided data cannot be processed by this formatter. Return the source data if it is valid. The data may be encapsulated or converted if necessary.</em> |
| public | <strong>write(</strong><em>\Symfony\Component\Console\Output\OutputInterface</em> <strong>$output</strong>, <em>mixed</em> <strong>$data</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>string</em><br /><em>Given structured data, apply appropriate formatting, and return a printable string.</em> |
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface), [\Consolidation\OutputFormatters\Validate\ValidDataTypesInterface](#interface-consolidationoutputformattersvalidatevaliddatatypesinterface), [\Consolidation\OutputFormatters\Validate\ValidationInterface](#interface-consolidationoutputformattersvalidatevalidationinterface)*
<hr />
### Class: \Consolidation\OutputFormatters\Formatters\YamlFormatter
> Yaml formatter Convert an array or ArrayObject into Yaml.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>write(</strong><em>\Symfony\Component\Console\Output\OutputInterface</em> <strong>$output</strong>, <em>mixed</em> <strong>$data</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>string</em><br /><em>Given structured data, apply appropriate formatting, and return a printable string.</em> |
*This class implements [\Consolidation\OutputFormatters\Formatters\FormatterInterface](#interface-consolidationoutputformattersformattersformatterinterface)*
<hr />
### Class: \Consolidation\OutputFormatters\Options\FormatterOptions
> FormetterOptions holds information that affects the way a formatter renders its output. There are three places where a formatter might get options from: 1. Configuration associated with the command that produced the output. This is passed in to FormatterManager::write() along with the data to format. It might originally come from annotations on the command, or it might come from another source. Examples include the field labels for a table, or the default list of fields to display. 2. Options specified by the user, e.g. by commandline options. 3. Default values associated with the formatter itself. This class caches configuration from sources (1) and (2), and expects to be provided the defaults, (3), whenever a value is requested.
@@ -347,9 +380,11 @@
| public | <strong>setConfigurationDefault(</strong><em>string</em> <strong>$key</strong>, <em>mixed</em> <strong>$value</strong>)</strong> : <em>\Consolidation\OutputFormatters\Options\FormetterOptions</em><br /><em>Change one configuration value for this formatter option, but only if it does not already have a value set.</em> |
| public | <strong>setDefaultFields(</strong><em>mixed</em> <strong>$fields</strong>)</strong> : <em>void</em> |
| public | <strong>setDefaultStringField(</strong><em>mixed</em> <strong>$defaultStringField</strong>)</strong> : <em>void</em> |
| public | <strong>setDelimiter(</strong><em>mixed</em> <strong>$delimiter</strong>)</strong> : <em>void</em> |
| public | <strong>setFieldLabels(</strong><em>mixed</em> <strong>$fieldLabels</strong>)</strong> : <em>void</em> |
| public | <strong>setIncludeFieldLables(</strong><em>mixed</em> <strong>$includFieldLables</strong>)</strong> : <em>void</em> |
| public | <strong>setInput(</strong><em>\Symfony\Component\Console\Input\InputInterface</em> <strong>$input</strong>)</strong> : <em>\Consolidation\OutputFormatters\Options\type</em><br /><em>Provide a Symfony Console InputInterface containing the user-specified options for this request.</em> |
| public | <strong>setListDelimiter(</strong><em>mixed</em> <strong>$listDelimiter</strong>)</strong> : <em>void</em> |
| public | <strong>setListOrientation(</strong><em>mixed</em> <strong>$listOrientation</strong>)</strong> : <em>void</em> |
| public | <strong>setOption(</strong><em>string</em> <strong>$key</strong>, <em>mixed</em> <strong>$value</strong>)</strong> : <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em><br /><em>Change one option value specified by the user for this request.</em> |
| public | <strong>setOptions(</strong><em>array</em> <strong>$options</strong>)</strong> : <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em><br /><em>Set all of the options that were specified by the user for this request.</em> |
@@ -363,14 +398,67 @@
| protected | <strong>parse(</strong><em>string</em> <strong>$key</strong>, <em>mixed</em> <strong>$value</strong>)</strong> : <em>mixed</em><br /><em>Given the raw value for a specific key, do any type conversion (e.g. from a textual list to an array) needed for the data.</em> |
| protected | <strong>setConfigurationValue(</strong><em>string</em> <strong>$key</strong>, <em>mixed</em> <strong>$value</strong>)</strong> : <em>\Consolidation\OutputFormatters\Options\FormetterOptions</em><br /><em>Change one configuration value for this formatter option.</em> |
<hr />
### Interface: \Consolidation\OutputFormatters\Options\OverrideOptionsInterface
<hr />
### Interface: \Consolidation\OutputFormatters\StructuredData\ListDataInterface
| Visibility | Function |
|:-----------|:---------|
| public | <strong>overrideOptions(</strong><em>mixed</em> <strong>$structuredOutput</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em><br /><em>Allow the formatter to mess with the configuration options before any transformations et. al. get underway.</em> |
| public | <strong>getListData(</strong><em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>array</em><br /><em>Convert data to a format suitable for use in a list. By default, the array values will be used. Implement ListDataInterface to use some other criteria (e.g. array keys).</em> |
<hr />
### Interface: \Consolidation\OutputFormatters\StructuredData\TableDataInterface
| Visibility | Function |
|:-----------|:---------|
| public | <strong>getOriginalData()</strong> : <em>mixed</em><br /><em>Return the original data for this table. Used by any formatter that is -not- a table.</em> |
| public | <strong>getTableData(</strong><em>bool/boolean</em> <strong>$includeRowKey=false</strong>)</strong> : <em>array</em><br /><em>Convert structured data into a form suitable for use by the table formatter. key from each row.</em> |
<hr />
### Class: \Consolidation\OutputFormatters\StructuredData\HelpDocument
| Visibility | Function |
|:-----------|:---------|
| public | <strong>getDomData()</strong> : <em>[\DomDocument](http://php.net/manual/en/class.domdocument.php)</em><br /><em>Convert data into a \DomDocument.</em> |
*This class implements [\Consolidation\OutputFormatters\StructuredData\Xml\DomDataInterface](#interface-consolidationoutputformattersstructureddataxmldomdatainterface)*
<hr />
### Interface: \Consolidation\OutputFormatters\StructuredData\OriginalDataInterface
| Visibility | Function |
|:-----------|:---------|
| public | <strong>getOriginalData()</strong> : <em>mixed</em><br /><em>Return the original data for this table. Used by any formatter that expects an array.</em> |
<hr />
### Class: \Consolidation\OutputFormatters\StructuredData\RowsOfFields
> Holds an array where each element of the array is one row, and each row contains an associative array where the keys are the field names, and the values are the field data. It is presumed that every row contains the same keys.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>getListData(</strong><em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>mixed</em> |
| public | <strong>restructure(</strong><em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>\Consolidation\OutputFormatters\StructuredData\Consolidation\OutputFormatters\Transformations\TableTransformation</em><br /><em>Restructure this data for output by converting it into a table transformation object.</em> |
| protected | <strong>defaultOptions()</strong> : <em>void</em> |
*This class extends [\Consolidation\OutputFormatters\StructuredData\AbstractStructuredList](#class-consolidationoutputformattersstructureddataabstractstructuredlist-abstract)*
*This class implements [\Consolidation\OutputFormatters\StructuredData\RenderCellInterface](#interface-consolidationoutputformattersstructureddatarendercellinterface), [\Consolidation\OutputFormatters\StructuredData\RenderCellCollectionInterface](#interface-consolidationoutputformattersstructureddatarendercellcollectioninterface), [\Consolidation\OutputFormatters\StructuredData\RestructureInterface](#interface-consolidationoutputformattersstructureddatarestructureinterface), \Countable, \Serializable, \ArrayAccess, \Traversable, \IteratorAggregate, [\Consolidation\OutputFormatters\StructuredData\ListDataInterface](#interface-consolidationoutputformattersstructureddatalistdatainterface)*
<hr />
### Interface: \Consolidation\OutputFormatters\StructuredData\RestructureInterface
| Visibility | Function |
|:-----------|:---------|
| public | <strong>restructure(</strong><em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>void</em><br /><em>Allow structured data to be restructured -- i.e. to select fields to show, reorder fields, etc.</em> |
<hr />
<hr />
### Class: \Consolidation\OutputFormatters\StructuredData\AbstractStructuredList (abstract)
> Holds an array where each element of the array is one row, and each row contains an associative array where the keys are the field names, and the values are the field data. It is presumed that every row contains the same keys.
@@ -380,7 +468,6 @@
| public | <strong>__construct(</strong><em>mixed</em> <strong>$data</strong>)</strong> : <em>void</em> |
| public | <strong>addRenderer(</strong><em>[\Consolidation\OutputFormatters\StructuredData\RenderCellInterface](#interface-consolidationoutputformattersstructureddatarendercellinterface)</em> <strong>$renderer</strong>, <em>string</em> <strong>$priority=`'normal'`</strong>)</strong> : <em>\Consolidation\OutputFormatters\StructuredData\$this</em><br /><em>Add a renderer</em> |
| public | <strong>addRendererFunction(</strong><em>\callable</em> <strong>$rendererFn</strong>, <em>string</em> <strong>$priority=`'normal'`</strong>)</strong> : <em>\Consolidation\OutputFormatters\StructuredData\$this</em><br /><em>Add a callable as a renderer</em> |
| public | <strong>abstract getListData(</strong><em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>mixed</em> |
| public | <strong>renderCell(</strong><em>mixed</em> <strong>$key</strong>, <em>mixed</em> <strong>$cellData</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>, <em>mixed</em> <strong>$rowData</strong>)</strong> : <em>void</em> |
| public | <strong>abstract restructure(</strong><em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>void</em> |
| protected | <strong>createTableTransformation(</strong><em>mixed</em> <strong>$data</strong>, <em>mixed</em> <strong>$options</strong>)</strong> : <em>mixed</em> |
@@ -389,47 +476,27 @@
| protected | <strong>getReorderedFieldLabels(</strong><em>mixed</em> <strong>$data</strong>, <em>mixed</em> <strong>$options</strong>, <em>mixed</em> <strong>$defaults</strong>)</strong> : <em>mixed</em> |
| protected | <strong>instantiateTableTransformation(</strong><em>mixed</em> <strong>$data</strong>, <em>mixed</em> <strong>$fieldLabels</strong>, <em>mixed</em> <strong>$rowLabels</strong>)</strong> : <em>void</em> |
*This class extends [\Consolidation\OutputFormatters\StructuredData\ListDataFromKeys](#class-consolidationoutputformattersstructureddatalistdatafromkeys)*
*This class implements [\Consolidation\OutputFormatters\StructuredData\ListDataInterface](#interface-consolidationoutputformattersstructureddatalistdatainterface), \IteratorAggregate, \Traversable, \ArrayAccess, \Serializable, \Countable, [\Consolidation\OutputFormatters\StructuredData\RestructureInterface](#interface-consolidationoutputformattersstructureddatarestructureinterface), [\Consolidation\OutputFormatters\StructuredData\RenderCellCollectionInterface](#interface-consolidationoutputformattersstructureddatarendercellcollectioninterface), [\Consolidation\OutputFormatters\StructuredData\RenderCellInterface](#interface-consolidationoutputformattersstructureddatarendercellinterface)*
<hr />
### Class: \Consolidation\OutputFormatters\StructuredData\ListDataFromKeys
> Represents aribtrary array data (structured or unstructured) where the data to display in --list format comes from the array keys.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>__construct(</strong><em>mixed</em> <strong>$data</strong>)</strong> : <em>void</em> |
| public | <strong>getListData(</strong><em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>mixed</em> |
*This class extends \ArrayObject*
*This class implements \Countable, \Serializable, \ArrayAccess, \Traversable, \IteratorAggregate, [\Consolidation\OutputFormatters\StructuredData\RestructureInterface](#interface-consolidationoutputformattersstructureddatarestructureinterface), [\Consolidation\OutputFormatters\StructuredData\ListDataInterface](#interface-consolidationoutputformattersstructureddatalistdatainterface), [\Consolidation\OutputFormatters\StructuredData\RenderCellCollectionInterface](#interface-consolidationoutputformattersstructureddatarendercellcollectioninterface), [\Consolidation\OutputFormatters\StructuredData\RenderCellInterface](#interface-consolidationoutputformattersstructureddatarendercellinterface)*
*This class implements \Countable, \Serializable, \ArrayAccess, \Traversable, \IteratorAggregate, [\Consolidation\OutputFormatters\StructuredData\ListDataInterface](#interface-consolidationoutputformattersstructureddatalistdatainterface)*
<hr />
### Class: \Consolidation\OutputFormatters\StructuredData\AssociativeList
<hr />
> Old name for PropertyList class.
| Visibility | Function |
|:-----------|:---------|
*This class extends [\Consolidation\OutputFormatters\StructuredData\PropertyList](#class-consolidationoutputformattersstructureddatapropertylist)*
*This class implements \Countable, \Serializable, \ArrayAccess, \Traversable, \IteratorAggregate, [\Consolidation\OutputFormatters\StructuredData\RestructureInterface](#interface-consolidationoutputformattersstructureddatarestructureinterface), [\Consolidation\OutputFormatters\StructuredData\ListDataInterface](#interface-consolidationoutputformattersstructureddatalistdatainterface), [\Consolidation\OutputFormatters\StructuredData\RenderCellCollectionInterface](#interface-consolidationoutputformattersstructureddatarendercellcollectioninterface), [\Consolidation\OutputFormatters\StructuredData\RenderCellInterface](#interface-consolidationoutputformattersstructureddatarendercellinterface)*
<hr />
### Class: \Consolidation\OutputFormatters\StructuredData\CallableRenderer
| Visibility | Function |
|:-----------|:---------|
| public | <strong>__construct(</strong><em>\callable</em> <strong>$renderFunction</strong>)</strong> : <em>void</em> |
| public | <strong>renderCell(</strong><em>mixed</em> <strong>$key</strong>, <em>mixed</em> <strong>$cellData</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>, <em>mixed</em> <strong>$rowData</strong>)</strong> : <em>void</em> |
*This class implements [\Consolidation\OutputFormatters\StructuredData\RenderCellInterface](#interface-consolidationoutputformattersstructureddatarendercellinterface)*
<hr />
### Interface: \Consolidation\OutputFormatters\StructuredData\ListDataInterface
| Visibility | Function |
|:-----------|:---------|
| public | <strong>getListData(</strong><em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>array</em><br /><em>Convert data to a format suitable for use in a list. By default, the array values will be used. Implement ListDataInterface to use some other criteria (e.g. array keys).</em> |
<hr />
### Interface: \Consolidation\OutputFormatters\StructuredData\OriginalDataInterface
| Visibility | Function |
|:-----------|:---------|
| public | <strong>getOriginalData()</strong> : <em>mixed</em><br /><em>Return the original data for this table. Used by any formatter that expects an array.</em> |
<hr />
### Class: \Consolidation\OutputFormatters\StructuredData\PropertyList
> Holds an array where each element of the array is one key : value pair. The keys must be unique, as is typically the case for associative arrays.
@@ -443,9 +510,29 @@
*This class extends [\Consolidation\OutputFormatters\StructuredData\AbstractStructuredList](#class-consolidationoutputformattersstructureddataabstractstructuredlist-abstract)*
*This class implements [\Consolidation\OutputFormatters\StructuredData\RenderCellInterface](#interface-consolidationoutputformattersstructureddatarendercellinterface), [\Consolidation\OutputFormatters\StructuredData\RenderCellCollectionInterface](#interface-consolidationoutputformattersstructureddatarendercellcollectioninterface), [\Consolidation\OutputFormatters\StructuredData\ListDataInterface](#interface-consolidationoutputformattersstructureddatalistdatainterface), [\Consolidation\OutputFormatters\StructuredData\RestructureInterface](#interface-consolidationoutputformattersstructureddatarestructureinterface), \IteratorAggregate, \Traversable, \ArrayAccess, \Serializable, \Countable*
*This class implements [\Consolidation\OutputFormatters\StructuredData\RenderCellInterface](#interface-consolidationoutputformattersstructureddatarendercellinterface), [\Consolidation\OutputFormatters\StructuredData\RenderCellCollectionInterface](#interface-consolidationoutputformattersstructureddatarendercellcollectioninterface), [\Consolidation\OutputFormatters\StructuredData\RestructureInterface](#interface-consolidationoutputformattersstructureddatarestructureinterface), \Countable, \Serializable, \ArrayAccess, \Traversable, \IteratorAggregate, [\Consolidation\OutputFormatters\StructuredData\ListDataInterface](#interface-consolidationoutputformattersstructureddatalistdatainterface)*
<hr />
### Interface: \Consolidation\OutputFormatters\StructuredData\RenderCellInterface
| Visibility | Function |
|:-----------|:---------|
| public | <strong>renderCell(</strong><em>string</em> <strong>$key</strong>, <em>mixed</em> <strong>$cellData</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>, <em>array</em> <strong>$rowData</strong>)</strong> : <em>mixed</em><br /><em>Convert the contents of one table cell into a string, so that it may be placed in the table. Renderer should return the $cellData passed to it if it does not wish to process it.</em> |
<hr />
### Class: \Consolidation\OutputFormatters\StructuredData\CallableRenderer
| Visibility | Function |
|:-----------|:---------|
| public | <strong>__construct(</strong><em>\callable</em> <strong>$renderFunction</strong>)</strong> : <em>void</em> |
| public | <strong>renderCell(</strong><em>mixed</em> <strong>$key</strong>, <em>mixed</em> <strong>$cellData</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>, <em>mixed</em> <strong>$rowData</strong>)</strong> : <em>void</em> |
*This class implements [\Consolidation\OutputFormatters\StructuredData\RenderCellInterface](#interface-consolidationoutputformattersstructureddatarendercellinterface)*
<hr />
<hr />
### Interface: \Consolidation\OutputFormatters\StructuredData\RenderCellCollectionInterface
| Visibility | Function |
@@ -454,51 +541,39 @@
*This class implements [\Consolidation\OutputFormatters\StructuredData\RenderCellInterface](#interface-consolidationoutputformattersstructureddatarendercellinterface)*
<hr />
### Interface: \Consolidation\OutputFormatters\StructuredData\RenderCellInterface
<hr />
### Class: \Consolidation\OutputFormatters\StructuredData\AssociativeList
> Old name for PropertyList class.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>renderCell(</strong><em>string</em> <strong>$key</strong>, <em>mixed</em> <strong>$cellData</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>, <em>array</em> <strong>$rowData</strong>)</strong> : <em>mixed</em><br /><em>Convert the contents of one table cell into a string, so that it may be placed in the table. Renderer should return the $cellData passed to it if it does not wish to process it.</em> |
<hr />
### Interface: \Consolidation\OutputFormatters\StructuredData\RestructureInterface
*This class extends [\Consolidation\OutputFormatters\StructuredData\PropertyList](#class-consolidationoutputformattersstructureddatapropertylist)*
*This class implements [\Consolidation\OutputFormatters\StructuredData\ListDataInterface](#interface-consolidationoutputformattersstructureddatalistdatainterface), \IteratorAggregate, \Traversable, \ArrayAccess, \Serializable, \Countable, [\Consolidation\OutputFormatters\StructuredData\RestructureInterface](#interface-consolidationoutputformattersstructureddatarestructureinterface), [\Consolidation\OutputFormatters\StructuredData\RenderCellCollectionInterface](#interface-consolidationoutputformattersstructureddatarendercellcollectioninterface), [\Consolidation\OutputFormatters\StructuredData\RenderCellInterface](#interface-consolidationoutputformattersstructureddatarendercellinterface)*
<hr />
### Interface: \Consolidation\OutputFormatters\StructuredData\Xml\XmlSchemaInterface
> When using arrays, we could represent XML data in a number of different ways. For example, given the following XML data strucutre: <document id="1" name="doc"> <foobars> <foobar id="123"> <name>blah</name> <widgets> <widget> <foo>a</foo> <bar>b</bar> <baz>c</baz> </widget> </widgets> </foobar> </foobars> </document> This could be: [ 'id' => 1, 'name' => 'doc', 'foobars' => [ [ 'id' => '123', 'name' => 'blah', 'widgets' => [ [ 'foo' => 'a', 'bar' => 'b', 'baz' => 'c', ] ], ], ] ] The challenge is more in going from an array back to the more structured xml format. Note that any given key => string mapping could represent either an attribute, or a simple XML element containing only a string value. In general, we do *not* want to add extra layers of nesting in the data structure to disambiguate between these kinds of data, as we want the source data to render cleanly into other formats, e.g. yaml, json, et. al., and we do not want to force every data provider to have to consider the optimal xml schema for their data. Our strategy, therefore, is to expect clients that wish to provide a very specific xml representation to return a DOMDocument, and, for other data structures where xml is a secondary concern, then we will use some default heuristics to convert from arrays to xml.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>restructure(</strong><em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>void</em><br /><em>Allow structured data to be restructured -- i.e. to select fields to show, reorder fields, etc.</em> |
| public | <strong>arrayToXml(</strong><em>mixed</em> <strong>$structuredData</strong>)</strong> : <em>[\DOMDocument](http://php.net/manual/en/class.domdocument.php)</em><br /><em>Convert data to a format suitable for use in a list. By default, the array values will be used. Implement ListDataInterface to use some other criteria (e.g. array keys).</em> |
<hr />
### Class: \Consolidation\OutputFormatters\StructuredData\RowsOfFields
<hr />
> Holds an array where each element of the array is one row, and each row contains an associative array where the keys are the field names, and the values are the field data. It is presumed that every row contains the same keys.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>getListData(</strong><em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>mixed</em> |
| public | <strong>restructure(</strong><em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>\Consolidation\OutputFormatters\StructuredData\Consolidation\OutputFormatters\Transformations\TableTransformation</em><br /><em>Restructure this data for output by converting it into a table transformation object.</em> |
| protected | <strong>defaultOptions()</strong> : <em>void</em> |
*This class extends [\Consolidation\OutputFormatters\StructuredData\AbstractStructuredList](#class-consolidationoutputformattersstructureddataabstractstructuredlist-abstract)*
*This class implements [\Consolidation\OutputFormatters\StructuredData\RenderCellInterface](#interface-consolidationoutputformattersstructureddatarendercellinterface), [\Consolidation\OutputFormatters\StructuredData\RenderCellCollectionInterface](#interface-consolidationoutputformattersstructureddatarendercellcollectioninterface), [\Consolidation\OutputFormatters\StructuredData\ListDataInterface](#interface-consolidationoutputformattersstructureddatalistdatainterface), [\Consolidation\OutputFormatters\StructuredData\RestructureInterface](#interface-consolidationoutputformattersstructureddatarestructureinterface), \IteratorAggregate, \Traversable, \ArrayAccess, \Serializable, \Countable*
<hr />
### Interface: \Consolidation\OutputFormatters\StructuredData\TableDataInterface
| Visibility | Function |
|:-----------|:---------|
| public | <strong>getOriginalData()</strong> : <em>mixed</em><br /><em>Return the original data for this table. Used by any formatter that is -not- a table.</em> |
| public | <strong>getTableData(</strong><em>bool/boolean</em> <strong>$includeRowKey=false</strong>)</strong> : <em>array</em><br /><em>Convert structured data into a form suitable for use by the table formatter. key from each row.</em> |
<hr />
### Interface: \Consolidation\OutputFormatters\StructuredData\Xml\DomDataInterface
| Visibility | Function |
|:-----------|:---------|
| public | <strong>getDomData()</strong> : <em>[\DomDocument](http://php.net/manual/en/class.domdocument.php)</em><br /><em>Convert data into a \DomDocument.</em> |
<hr />
<hr />
### Class: \Consolidation\OutputFormatters\StructuredData\Xml\XmlSchema
| Visibility | Function |
@@ -508,6 +583,7 @@
| protected | <strong>addXmlChildren(</strong><em>[\DOMDocument](http://php.net/manual/en/class.domdocument.php)</em> <strong>$dom</strong>, <em>mixed</em> <strong>$xmlParent</strong>, <em>mixed</em> <strong>$elementName</strong>, <em>mixed</em> <strong>$structuredData</strong>)</strong> : <em>void</em> |
| protected | <strong>addXmlData(</strong><em>[\DOMDocument](http://php.net/manual/en/class.domdocument.php)</em> <strong>$dom</strong>, <em>mixed</em> <strong>$xmlParent</strong>, <em>mixed</em> <strong>$elementName</strong>, <em>mixed</em> <strong>$structuredData</strong>)</strong> : <em>void</em> |
| protected | <strong>addXmlDataOrAttribute(</strong><em>[\DOMDocument](http://php.net/manual/en/class.domdocument.php)</em> <strong>$dom</strong>, <em>mixed</em> <strong>$xmlParent</strong>, <em>mixed</em> <strong>$elementName</strong>, <em>mixed</em> <strong>$key</strong>, <em>mixed</em> <strong>$value</strong>)</strong> : <em>void</em> |
| protected | <strong>determineElementName(</strong><em>mixed</em> <strong>$key</strong>, <em>mixed</em> <strong>$childElementName</strong>, <em>mixed</em> <strong>$value</strong>)</strong> : <em>void</em> |
| protected | <strong>getDefaultElementName(</strong><em>mixed</em> <strong>$parentElementName</strong>)</strong> : <em>mixed</em> |
| protected | <strong>getTopLevelElementName(</strong><em>mixed</em> <strong>$structuredData</strong>)</strong> : <em>mixed</em> |
| protected | <strong>inElementList(</strong><em>mixed</em> <strong>$parentElementName</strong>, <em>mixed</em> <strong>$elementName</strong>)</strong> : <em>void</em> |
@@ -517,44 +593,18 @@
*This class implements [\Consolidation\OutputFormatters\StructuredData\Xml\XmlSchemaInterface](#interface-consolidationoutputformattersstructureddataxmlxmlschemainterface)*
<hr />
### Interface: \Consolidation\OutputFormatters\StructuredData\Xml\XmlSchemaInterface
<hr />
> When using arrays, we could represent XML data in a number of different ways. For example, given the following XML data strucutre: <document id="1" name="doc"> <foobars> <foobar id="123"> <name>blah</name> <widgets> <widget> <foo>a</foo> <bar>b</bar> <baz>c</baz> </widget> </widgets> </foobar> </foobars> </document> This could be: [ 'id' => 1, 'name' => 'doc', 'foobars' => [ [ 'id' => '123', 'name' => 'blah', 'widgets' => [ [ 'foo' => 'a', 'bar' => 'b', 'baz' => 'c', ] ], ], ] ] The challenge is more in going from an array back to the more structured xml format. Note that any given key => string mapping could represent either an attribute, or a simple XML element containing only a string value. In general, we do *not* want to add extra layers of nesting in the data structure to disambiguate between these kinds of data, as we want the source data to render cleanly into other formats, e.g. yaml, json, et. al., and we do not want to force every data provider to have to consider the optimal xml schema for their data. Our strategy, therefore, is to expect clients that wish to provide a very specific xml representation to return a DOMDocument, and, for other data structures where xml is a secondary concern, then we will use some default heuristics to convert from arrays to xml.
### Class: \Consolidation\OutputFormatters\Transformations\PropertyParser
> Transform a string of properties into a PHP associative array. Input: one: red two: white three: blue Output: [ 'one' => 'red', 'two' => 'white', 'three' => 'blue', ]
| Visibility | Function |
|:-----------|:---------|
| public | <strong>arrayToXml(</strong><em>mixed</em> <strong>$structuredData</strong>)</strong> : <em>[\DOMDocument](http://php.net/manual/en/class.domdocument.php)</em><br /><em>Convert data to a format suitable for use in a list. By default, the array values will be used. Implement ListDataInterface to use some other criteria (e.g. array keys).</em> |
| public static | <strong>parse(</strong><em>mixed</em> <strong>$data</strong>)</strong> : <em>void</em> |
<hr />
### Class: \Consolidation\OutputFormatters\Transformations\DomToArraySimplifier
<hr />
> Simplify a DOMDocument to an array.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>__construct()</strong> : <em>void</em> |
| public | <strong>canSimplify(</strong><em>[\ReflectionClass](http://php.net/manual/en/class.reflectionclass.php)</em> <strong>$dataType</strong>)</strong> : <em>bool</em> |
| public | <strong>simplifyToArray(</strong><em>mixed</em> <strong>$structuredData</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>void</em> |
| protected | <strong>elementToArray(</strong><em>[\DOMNode](http://php.net/manual/en/class.domnode.php)</em> <strong>$element</strong>)</strong> : <em>array</em><br /><em>Recursively convert the provided DOM element into a php array.</em> |
| protected | <strong>getNodeAttributes(</strong><em>[\DOMNode](http://php.net/manual/en/class.domnode.php)</em> <strong>$element</strong>)</strong> : <em>array</em><br /><em>Get all of the attributes of the provided element.</em> |
| protected | <strong>getNodeChildren(</strong><em>[\DOMNode](http://php.net/manual/en/class.domnode.php)</em> <strong>$element</strong>)</strong> : <em>array</em><br /><em>Get all of the children of the provided element, with simplification.</em> |
| protected | <strong>getNodeChildrenData(</strong><em>[\DOMNode](http://php.net/manual/en/class.domnode.php)</em> <strong>$element</strong>)</strong> : <em>array</em><br /><em>Get the data from the children of the provided node in preliminary form.</em> |
| protected | <strong>getUniformChildren(</strong><em>string</em> <strong>$parentKey</strong>, <em>[\DOMNode](http://php.net/manual/en/class.domnode.php)</em> <strong>$element</strong>)</strong> : <em>array</em><br /><em>Convert the children of the provided DOM element into an array. Here, 'uniform' means that all of the element names of the children are identical, and further, the element name of the parent is the plural form of the child names. When the children are uniform in this way, then the parent element name will be used as the key to store the children in, and the child list will be returned as a simple list with their (duplicate) element names omitted.</em> |
| protected | <strong>getUniqueChildren(</strong><em>string</em> <strong>$parentKey</strong>, <em>[\DOMNode](http://php.net/manual/en/class.domnode.php)</em> <strong>$element</strong>)</strong> : <em>array</em><br /><em>Convert the children of the provided DOM element into an array. Here, 'unique' means that all of the element names of the children are different. Since the element names will become the key of the associative array that is returned, so duplicates are not supported. If there are any duplicates, then an exception will be thrown.</em> |
| protected | <strong>hasUniformChildren(</strong><em>[\DOMNode](http://php.net/manual/en/class.domnode.php)</em> <strong>$element</strong>)</strong> : <em>boolean</em><br /><em>Determine whether the children of the provided element are uniform.</em> |
| protected | <strong>valueCanBeSimplified(</strong><em>[\DOMNode](http://php.net/manual/en/class.domnode.php)</em> <strong>$value</strong>)</strong> : <em>boolean</em><br /><em>Determine whether the provided value has additional unnecessary nesting. {"color": "red"} is converted to "red". No other simplification is done.</em> |
*This class implements [\Consolidation\OutputFormatters\Transformations\SimplifyToArrayInterface](#interface-consolidationoutputformatterstransformationssimplifytoarrayinterface)*
<hr />
### Interface: \Consolidation\OutputFormatters\Transformations\OverrideRestructureInterface
| Visibility | Function |
|:-----------|:---------|
| public | <strong>overrideRestructure(</strong><em>mixed</em> <strong>$structuredOutput</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>mixed</em><br /><em>Select data to use directly from the structured output, before the restructure operation has been executed.</em> |
<hr />
### Class: \Consolidation\OutputFormatters\Transformations\PropertyListTableTransformation
| Visibility | Function |
@@ -565,38 +615,8 @@
*This class implements [\Consolidation\OutputFormatters\StructuredData\OriginalDataInterface](#interface-consolidationoutputformattersstructureddataoriginaldatainterface), [\Consolidation\OutputFormatters\StructuredData\TableDataInterface](#interface-consolidationoutputformattersstructureddatatabledatainterface), \IteratorAggregate, \Traversable, \ArrayAccess, \Serializable, \Countable*
<hr />
### Class: \Consolidation\OutputFormatters\Transformations\PropertyParser
<hr />
> Transform a string of properties into a PHP associative array. Input: one: red two: white three: blue Output: [ 'one' => 'red', 'two' => 'white', 'three' => 'blue', ]
| Visibility | Function |
|:-----------|:---------|
| public static | <strong>parse(</strong><em>mixed</em> <strong>$data</strong>)</strong> : <em>void</em> |
<hr />
### Class: \Consolidation\OutputFormatters\Transformations\ReorderFields
> Reorder the field labels based on the user-selected fields to display.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>reorder(</strong><em>string/array</em> <strong>$fields</strong>, <em>array</em> <strong>$fieldLabels</strong>, <em>array</em> <strong>$data</strong>)</strong> : <em>array</em><br /><em>Given a simple list of user-supplied field keys or field labels, return a reordered version of the field labels matching the user selection. key to the field label</em> |
| protected | <strong>convertToRegex(</strong><em>mixed</em> <strong>$str</strong>)</strong> : <em>void</em><br /><em>Convert the provided string into a regex suitable for use in preg_match. Matching occurs in the same way as the Symfony Finder component: http://symfony.com/doc/current/components/finder.html#file-name</em> |
| protected | <strong>getSelectedFieldKeys(</strong><em>mixed</em> <strong>$fields</strong>, <em>mixed</em> <strong>$fieldLabels</strong>)</strong> : <em>mixed</em> |
| protected | <strong>isRegex(</strong><em>string</em> <strong>$str</strong>)</strong> : <em>bool Whether the given string is a regex</em><br /><em>Checks whether the string is a regex. This function is copied from MultiplePcreFilterIterator in the Symfony Finder component.</em> |
| protected | <strong>matchFieldInLabelMap(</strong><em>mixed</em> <strong>$field</strong>, <em>mixed</em> <strong>$fieldLabels</strong>)</strong> : <em>void</em> |
| protected | <strong>reorderFieldLabels(</strong><em>mixed</em> <strong>$fields</strong>, <em>mixed</em> <strong>$fieldLabels</strong>, <em>mixed</em> <strong>$data</strong>)</strong> : <em>void</em> |
<hr />
### Interface: \Consolidation\OutputFormatters\Transformations\SimplifyToArrayInterface
| Visibility | Function |
|:-----------|:---------|
| public | <strong>canSimplify(</strong><em>[\ReflectionClass](http://php.net/manual/en/class.reflectionclass.php)</em> <strong>$structuredOutput</strong>)</strong> : <em>bool</em><br /><em>Indicate whether or not the given data type can be simplified to an array</em> |
| public | <strong>simplifyToArray(</strong><em>mixed</em> <strong>$structuredOutput</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>array</em><br /><em>Convert structured data into a generic array, usable by generic array-based formatters. Objects that implement this interface may be attached to the FormatterManager, and will be used on any data structure that needs to be simplified into an array. An array simplifier should take no action other than to return its input data if it cannot simplify the provided data into an array.</em> |
<hr />
### Class: \Consolidation\OutputFormatters\Transformations\TableTransformation
| Visibility | Function |
@@ -620,22 +640,124 @@
*This class implements \Countable, \Serializable, \ArrayAccess, \Traversable, \IteratorAggregate, [\Consolidation\OutputFormatters\StructuredData\TableDataInterface](#interface-consolidationoutputformattersstructureddatatabledatainterface), [\Consolidation\OutputFormatters\StructuredData\OriginalDataInterface](#interface-consolidationoutputformattersstructureddataoriginaldatainterface)*
<hr />
<hr />
### Class: \Consolidation\OutputFormatters\Transformations\ReorderFields
> Reorder the field labels based on the user-selected fields to display.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>reorder(</strong><em>string/array</em> <strong>$fields</strong>, <em>array</em> <strong>$fieldLabels</strong>, <em>array</em> <strong>$data</strong>)</strong> : <em>array</em><br /><em>Given a simple list of user-supplied field keys or field labels, return a reordered version of the field labels matching the user selection. key to the field label</em> |
| protected | <strong>convertToRegex(</strong><em>mixed</em> <strong>$str</strong>)</strong> : <em>void</em><br /><em>Convert the provided string into a regex suitable for use in preg_match. Matching occurs in the same way as the Symfony Finder component: http://symfony.com/doc/current/components/finder.html#file-name</em> |
| protected | <strong>getSelectedFieldKeys(</strong><em>mixed</em> <strong>$fields</strong>, <em>mixed</em> <strong>$fieldLabels</strong>)</strong> : <em>mixed</em> |
| protected | <strong>isRegex(</strong><em>string</em> <strong>$str</strong>)</strong> : <em>bool Whether the given string is a regex</em><br /><em>Checks whether the string is a regex. This function is copied from MultiplePcreFilterIterator in the Symfony Finder component.</em> |
| protected | <strong>matchFieldInLabelMap(</strong><em>mixed</em> <strong>$field</strong>, <em>mixed</em> <strong>$fieldLabels</strong>)</strong> : <em>void</em> |
| protected | <strong>reorderFieldLabels(</strong><em>mixed</em> <strong>$fields</strong>, <em>mixed</em> <strong>$fieldLabels</strong>, <em>mixed</em> <strong>$data</strong>)</strong> : <em>void</em> |
<hr />
### Class: \Consolidation\OutputFormatters\Transformations\DomToArraySimplifier
> Simplify a DOMDocument to an array.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>__construct()</strong> : <em>void</em> |
| public | <strong>canSimplify(</strong><em>[\ReflectionClass](http://php.net/manual/en/class.reflectionclass.php)</em> <strong>$dataType</strong>)</strong> : <em>bool</em> |
| public | <strong>simplifyToArray(</strong><em>mixed</em> <strong>$structuredData</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>void</em> |
| protected | <strong>elementToArray(</strong><em>[\DOMNode](http://php.net/manual/en/class.domnode.php)</em> <strong>$element</strong>)</strong> : <em>array</em><br /><em>Recursively convert the provided DOM element into a php array.</em> |
| protected | <strong>getIdOfValue(</strong><em>mixed</em> <strong>$value</strong>)</strong> : <em>string</em><br /><em>If the object has an 'id' or 'name' element, then use that as the array key when storing this value in its parent.</em> |
| protected | <strong>getNodeAttributes(</strong><em>[\DOMNode](http://php.net/manual/en/class.domnode.php)</em> <strong>$element</strong>)</strong> : <em>array</em><br /><em>Get all of the attributes of the provided element.</em> |
| protected | <strong>getNodeChildren(</strong><em>[\DOMNode](http://php.net/manual/en/class.domnode.php)</em> <strong>$element</strong>)</strong> : <em>array</em><br /><em>Get all of the children of the provided element, with simplification.</em> |
| protected | <strong>getNodeChildrenData(</strong><em>[\DOMNode](http://php.net/manual/en/class.domnode.php)</em> <strong>$element</strong>)</strong> : <em>array</em><br /><em>Get the data from the children of the provided node in preliminary form.</em> |
| protected | <strong>getUniformChildren(</strong><em>string</em> <strong>$parentKey</strong>, <em>[\DOMNode](http://php.net/manual/en/class.domnode.php)</em> <strong>$element</strong>)</strong> : <em>array</em><br /><em>Convert the children of the provided DOM element into an array. Here, 'uniform' means that all of the element names of the children are identical, and further, the element name of the parent is the plural form of the child names. When the children are uniform in this way, then the parent element name will be used as the key to store the children in, and the child list will be returned as a simple list with their (duplicate) element names omitted.</em> |
| protected | <strong>getUniqueChildren(</strong><em>string</em> <strong>$parentKey</strong>, <em>[\DOMNode](http://php.net/manual/en/class.domnode.php)</em> <strong>$element</strong>)</strong> : <em>array</em><br /><em>Convert the children of the provided DOM element into an array. Here, 'unique' means that all of the element names of the children are different. Since the element names will become the key of the associative array that is returned, so duplicates are not supported. If there are any duplicates, then an exception will be thrown.</em> |
| protected | <strong>hasUniformChildren(</strong><em>[\DOMNode](http://php.net/manual/en/class.domnode.php)</em> <strong>$element</strong>)</strong> : <em>boolean</em><br /><em>Determine whether the children of the provided element are uniform.</em> |
| protected | <strong>valueCanBeSimplified(</strong><em>[\DOMNode](http://php.net/manual/en/class.domnode.php)</em> <strong>$value</strong>)</strong> : <em>boolean</em><br /><em>Determine whether the provided value has additional unnecessary nesting. {"color": "red"} is converted to "red". No other simplification is done.</em> |
*This class implements [\Consolidation\OutputFormatters\Transformations\SimplifyToArrayInterface](#interface-consolidationoutputformatterstransformationssimplifytoarrayinterface)*
<hr />
### Class: \Consolidation\OutputFormatters\Transformations\WordWrapper
| Visibility | Function |
|:-----------|:---------|
| public | <strong>__construct(</strong><em>mixed</em> <strong>$width</strong>)</strong> : <em>void</em> |
| public | <strong>minimumWidth(</strong><em>mixed</em> <strong>$colkey</strong>, <em>mixed</em> <strong>$width</strong>)</strong> : <em>void</em><br /><em>Set the minimum width of just one column</em> |
| public | <strong>setMinimumWidths(</strong><em>array</em> <strong>$minimumWidths</strong>)</strong> : <em>void</em><br /><em>If columns have minimum widths, then set them here.</em> |
| public | <strong>setPaddingFromStyle(</strong><em>\Symfony\Component\Console\Helper\TableStyle</em> <strong>$style</strong>)</strong> : <em>void</em><br /><em>Calculate our padding widths from the specified table style.</em> |
| public | <strong>wrap(</strong><em>array</em> <strong>$rows</strong>, <em>array</em> <strong>$widths=array()</strong>)</strong> : <em>array</em><br /><em>Wrap the cells in each part of the provided data table</em> |
| protected | <strong>columnAutowidth(</strong><em>array</em> <strong>$rows</strong>, <em>array</em> <strong>$widths</strong>)</strong> : <em>void</em><br /><em>Determine the best fit for column widths. Ported from Drush. (in characters) - these will be left as is.</em> |
| protected static | <strong>longestWordLength(</strong><em>string</em> <strong>$str</strong>)</strong> : <em>int</em><br /><em>Return the length of the longest word in the string.</em> |
| protected | <strong>selectColumnToReduce(</strong><em>mixed</em> <strong>$col_dist</strong>, <em>mixed</em> <strong>$auto_widths</strong>, <em>mixed</em> <strong>$max_word_lens</strong>)</strong> : <em>void</em> |
| protected | <strong>shouldSelectThisColumn(</strong><em>mixed</em> <strong>$count</strong>, <em>mixed</em> <strong>$counts</strong>, <em>mixed</em> <strong>$width</strong>)</strong> : <em>bool</em> |
| protected | <strong>calculateWidths(</strong><em>mixed</em> <strong>$rows</strong>, <em>array</em> <strong>$widths=array()</strong>)</strong> : <em>void</em><br /><em>Determine what widths we'll use for wrapping.</em> |
| protected | <strong>wrapCell(</strong><em>mixed</em> <strong>$cell</strong>, <em>string</em> <strong>$cellWidth</strong>)</strong> : <em>mixed</em><br /><em>Wrap one cell. Guard against modifying non-strings and then call through to wordwrap().</em> |
<hr />
<hr />
### Interface: \Consolidation\OutputFormatters\Transformations\OverrideRestructureInterface
| Visibility | Function |
|:-----------|:---------|
| public | <strong>overrideRestructure(</strong><em>mixed</em> <strong>$structuredOutput</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>mixed</em><br /><em>Select data to use directly from the structured output, before the restructure operation has been executed.</em> |
<hr />
### Interface: \Consolidation\OutputFormatters\Transformations\SimplifyToArrayInterface
| Visibility | Function |
|:-----------|:---------|
| public | <strong>canSimplify(</strong><em>[\ReflectionClass](http://php.net/manual/en/class.reflectionclass.php)</em> <strong>$structuredOutput</strong>)</strong> : <em>bool</em><br /><em>Indicate whether or not the given data type can be simplified to an array</em> |
| public | <strong>simplifyToArray(</strong><em>mixed</em> <strong>$structuredOutput</strong>, <em>[\Consolidation\OutputFormatters\Options\FormatterOptions](#class-consolidationoutputformattersoptionsformatteroptions)</em> <strong>$options</strong>)</strong> : <em>array</em><br /><em>Convert structured data into a generic array, usable by generic array-based formatters. Objects that implement this interface may be attached to the FormatterManager, and will be used on any data structure that needs to be simplified into an array. An array simplifier should take no action other than to return its input data if it cannot simplify the provided data into an array.</em> |
<hr />
### Class: \Consolidation\OutputFormatters\Transformations\Wrap\CalculateWidths
> Calculate column widths for table cells. Influenced by Drush and webmozart/console.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>__construct()</strong> : <em>void</em> |
| public | <strong>calculate(</strong><em>mixed</em> <strong>$availableWidth</strong>, <em>[\Consolidation\OutputFormatters\Transformations\Wrap\ColumnWidths](#class-consolidationoutputformatterstransformationswrapcolumnwidths)</em> <strong>$dataWidths</strong>, <em>[\Consolidation\OutputFormatters\Transformations\Wrap\ColumnWidths](#class-consolidationoutputformatterstransformationswrapcolumnwidths)</em> <strong>$minimumWidths</strong>)</strong> : <em>void</em><br /><em>Given the total amount of available space, and the width of the columns to place, calculate the optimum column widths to use.</em> |
| public | <strong>calculateLongestCell(</strong><em>mixed</em> <strong>$rows</strong>)</strong> : <em>void</em><br /><em>Calculate the longest cell data from any row of each of the cells.</em> |
| public | <strong>calculateLongestWord(</strong><em>mixed</em> <strong>$rows</strong>)</strong> : <em>void</em><br /><em>Calculate the longest word and longest line in the provided data.</em> |
| public | <strong>distributeLongColumns(</strong><em>mixed</em> <strong>$availableWidth</strong>, <em>[\Consolidation\OutputFormatters\Transformations\Wrap\ColumnWidths](#class-consolidationoutputformatterstransformationswrapcolumnwidths)</em> <strong>$dataWidths</strong>, <em>[\Consolidation\OutputFormatters\Transformations\Wrap\ColumnWidths](#class-consolidationoutputformatterstransformationswrapcolumnwidths)</em> <strong>$minimumWidths</strong>)</strong> : <em>void</em><br /><em>Distribute the remainig space among the columns that were not included in the list of "short" columns.</em> |
| public | <strong>getShortColumns(</strong><em>mixed</em> <strong>$availableWidth</strong>, <em>[\Consolidation\OutputFormatters\Transformations\Wrap\ColumnWidths](#class-consolidationoutputformatterstransformationswrapcolumnwidths)</em> <strong>$dataWidths</strong>, <em>[\Consolidation\OutputFormatters\Transformations\Wrap\ColumnWidths](#class-consolidationoutputformatterstransformationswrapcolumnwidths)</em> <strong>$minimumWidths</strong>)</strong> : <em>mixed</em><br /><em>Return all of the columns whose longest line length is less than or equal to the average width.</em> |
| protected | <strong>calculateColumnWidths(</strong><em>mixed</em> <strong>$rows</strong>, <em>\callable</em> <strong>$fn</strong>)</strong> : <em>void</em> |
| protected static | <strong>longestWordLength(</strong><em>string</em> <strong>$str</strong>)</strong> : <em>int</em><br /><em>Return the length of the longest word in the string.</em> |
<hr />
### Class: \Consolidation\OutputFormatters\Transformations\Wrap\ColumnWidths
> Calculate the width of data in table cells in preparation for word wrapping.
| Visibility | Function |
|:-----------|:---------|
| public | <strong>__construct(</strong><em>array</em> <strong>$widths=array()</strong>)</strong> : <em>void</em> |
| public | <strong>adjustMinimumWidths(</strong><em>mixed</em> <strong>$availableWidth</strong>, <em>mixed</em> <strong>$dataCellWidths</strong>)</strong> : <em>void</em><br /><em>If the widths specified by this object do not fit within the provided avaiable width, then reduce them all proportionally.</em> |
| public | <strong>averageWidth(</strong><em>mixed</em> <strong>$availableWidth</strong>)</strong> : <em>void</em><br /><em>Calculate how much space is available on average for all columns.</em> |
| public | <strong>combine(</strong><em>[\Consolidation\OutputFormatters\Transformations\Wrap\ColumnWidths](#class-consolidationoutputformatterstransformationswrapcolumnwidths)</em> <strong>$combineWith</strong>)</strong> : <em>void</em><br /><em>Combine this set of widths with another set, and return a new set that contains the entries from both.</em> |
| public | <strong>count()</strong> : <em>void</em><br /><em>Return the number of columns.</em> |
| public | <strong>distribute(</strong><em>mixed</em> <strong>$availableWidth</strong>)</strong> : <em>void</em><br /><em>Return proportional weights</em> |
| public | <strong>enforceMinimums(</strong><em>mixed</em> <strong>$minimumWidths</strong>)</strong> : <em>void</em><br /><em>Ensure that every item in $widths that has a corresponding entry in $minimumWidths is as least as large as the minimum value held there.</em> |
| public | <strong>findShortColumns(</strong><em>mixed</em> <strong>$thresholdWidth</strong>)</strong> : <em>mixed</em><br /><em>Find all of the columns that are shorter than the specified threshold.</em> |
| public | <strong>findUndersizedColumns(</strong><em>mixed</em> <strong>$minimumWidths</strong>)</strong> : <em>mixed</em><br /><em>Find all of the columns that are shorter than the corresponding minimum widths.</em> |
| public | <strong>isEmpty()</strong> : <em>bool</em><br /><em>Return true if there is no data in this object</em> |
| public | <strong>keys()</strong> : <em>void</em><br /><em>Return the available keys (column identifiers) from the calculated data set.</em> |
| public | <strong>lastColumn()</strong> : <em>void</em> |
| public | <strong>paddingSpace(</strong><em>mixed</em> <strong>$paddingInEachCell</strong>, <em>mixed</em> <strong>$extraPaddingAtEndOfLine</strong>, <em>mixed</em> <strong>$extraPaddingAtBeginningOfLine</strong>)</strong> : <em>void</em> |
| public | <strong>removeColumns(</strong><em>mixed</em> <strong>$columnKeys</strong>)</strong> : <em>void</em><br /><em>Remove all of the specified columns from this data structure.</em> |
| public | <strong>selectColumns(</strong><em>mixed</em> <strong>$columnKeys</strong>)</strong> : <em>void</em><br /><em>Select all columns that exist in the provided list of keys.</em> |
| public | <strong>setWidth(</strong><em>mixed</em> <strong>$key</strong>, <em>mixed</em> <strong>$width</strong>)</strong> : <em>void</em><br /><em>Set the length of the specified column.</em> |
| public static | <strong>sumWidth(</strong><em>mixed</em> <strong>$widths</strong>)</strong> : <em>void</em><br /><em>Return the sum of the lengths of the provided widths.</em> |
| public | <strong>totalWidth()</strong> : <em>void</em><br /><em>Return the sum of the lengths of the provided widths.</em> |
| public | <strong>width(</strong><em>mixed</em> <strong>$key</strong>)</strong> : <em>void</em><br /><em>Return the length of the specified column.</em> |
| public | <strong>widths()</strong> : <em>void</em><br /><em>Return all of the lengths</em> |
| protected | <strong>findColumnsUnderThreshold(</strong><em>array</em> <strong>$thresholdWidths</strong>)</strong> : <em>mixed</em> |
<hr />
### Interface: \Consolidation\OutputFormatters\Validate\ValidationInterface
> Formatters may implement ValidationInterface in order to indicate whether a particular data structure is supported. Any formatter that does not implement ValidationInterface is assumed to only operate on arrays, or data types that implement SimplifyToArrayInterface.
@@ -645,7 +767,8 @@
| public | <strong>isValidDataType(</strong><em>[\ReflectionClass](http://php.net/manual/en/class.reflectionclass.php)</em> <strong>$dataType</strong>)</strong> : <em>bool</em><br /><em>Return true if the specified format is valid for use with this formatter.</em> |
| public | <strong>validate(</strong><em>mixed</em> <strong>$structuredData</strong>)</strong> : <em>mixed</em><br /><em>Throw an IncompatibleDataException if the provided data cannot be processed by this formatter. Return the source data if it is valid. The data may be encapsulated or converted if necessary.</em> |
<hr />
<hr />
### Interface: \Consolidation\OutputFormatters\Validate\ValidDataTypesInterface
> Formatters may implement ValidDataTypesInterface in order to indicate exactly which formats they support. The validDataTypes method can be called to retrieve a list of data types useful in providing hints in exception messages about which data types can be used with the formatter. Note that it is OPTIONAL for formatters to implement this interface. If a formatter implements only ValidationInterface, then clients that request the formatter via FormatterManager::write() will still get a list (via an InvalidFormatException) of all of the formats that are usable with the provided data type. Implementing ValidDataTypesInterface is benefitial to clients who instantiate a formatter directly (via `new`). Formatters that implement ValidDataTypesInterface may wish to use ValidDataTypesTrait.

View File

@@ -112,14 +112,14 @@ class FormatterManager
if (count($validFormats) > 1) {
// Make an input option for --format
$description = 'Format the result data. Available formats: ' . implode(',', $validFormats);
$automaticOptions[FormatterOptions::FORMAT] = new InputOption(FormatterOptions::FORMAT, '', InputOption::VALUE_OPTIONAL, $description, $defaultFormat);
$automaticOptions[FormatterOptions::FORMAT] = new InputOption(FormatterOptions::FORMAT, '', InputOption::VALUE_REQUIRED, $description, $defaultFormat);
}
if ($availableFields) {
$defaultFields = $options->get(FormatterOptions::DEFAULT_FIELDS, [], '');
$description = 'Available fields: ' . implode(', ', $this->availableFieldsList($availableFields));
$automaticOptions[FormatterOptions::FIELDS] = new InputOption(FormatterOptions::FIELDS, '', InputOption::VALUE_OPTIONAL, $description, $defaultFields);
$automaticOptions[FormatterOptions::FIELD] = new InputOption(FormatterOptions::FIELD, '', InputOption::VALUE_OPTIONAL, "Select just one field, and force format to 'string'.", '');
$automaticOptions[FormatterOptions::FIELDS] = new InputOption(FormatterOptions::FIELDS, '', InputOption::VALUE_REQUIRED, $description, $defaultFields);
$automaticOptions[FormatterOptions::FIELD] = new InputOption(FormatterOptions::FIELD, '', InputOption::VALUE_REQUIRED, "Select just one field, and force format to 'string'.", '');
}
return $automaticOptions;

View File

@@ -80,11 +80,26 @@ class TableFormatter implements FormatterInterface, ValidDataTypesInterface, Ren
$table->setStyle($options->get(FormatterOptions::TABLE_STYLE, $defaults));
$isList = $tableTransformer->isList();
$includeHeaders = $options->get(FormatterOptions::INCLUDE_FIELD_LABELS, $defaults);
$listDelimiter = $options->get(FormatterOptions::LIST_DELIMITER, $defaults);
$headers = $tableTransformer->getHeaders();
$data = $tableTransformer->getTableData($includeHeaders && $isList);
if ($listDelimiter) {
if (!empty($headers)) {
array_splice($headers, 1, 0, ':');
}
$data = array_map(function ($item) {
array_splice($item, 1, 0, ':');
return $item;
}, $data);
}
if ($includeHeaders && !$isList) {
$headers = $tableTransformer->getHeaders();
$table->setHeaders($headers);
}
$data = $tableTransformer->getTableData($includeHeaders && $isList);
// todo: $output->getFormatter();
$data = $this->wrap($headers, $data, $table->getStyle(), $options);
$table->setRows($data);
$table->render();

View File

@@ -51,6 +51,9 @@ class XmlFormatter implements FormatterInterface, ValidDataTypesInterface
if ($structuredData instanceof DomDataInterface) {
return $structuredData->getDomData();
}
if ($structuredData instanceof \ArrayObject) {
return $structuredData->getArrayCopy();
}
if (!is_array($structuredData)) {
throw new IncompatibleDataException(
$this,

View File

@@ -46,6 +46,7 @@ class FormatterOptions
const DEFAULT_FIELDS = 'default-fields';
const DEFAULT_STRING_FIELD = 'default-string-field';
const DELIMITER = 'delimiter';
const LIST_DELIMITER = 'list-delimiter';
const TERMINAL_WIDTH = 'width';
/**
@@ -83,6 +84,18 @@ class FormatterOptions
return $this->setConfigurationValue(self::TABLE_STYLE, $style);
}
public function setDelimiter($delimiter)
{
return $this->setConfigurationValue(self::DELIMITER, $delimiter);
}
public function setListDelimiter($listDelimiter)
{
return $this->setConfigurationValue(self::LIST_DELIMITER, $listDelimiter);
}
public function setIncludeFieldLables($includFieldLables)
{
return $this->setConfigurationValue(self::INCLUDE_FIELD_LABELS, $includFieldLables);

View File

@@ -14,10 +14,9 @@ use Consolidation\OutputFormatters\Transformations\TableTransformation;
*
* It is presumed that every row contains the same keys.
*/
abstract class AbstractStructuredList extends \ArrayObject implements RestructureInterface, ListDataInterface, RenderCellCollectionInterface
abstract class AbstractStructuredList extends ListDataFromKeys implements RestructureInterface, RenderCellCollectionInterface
{
use RenderCellCollectionTrait;
protected $data;
public function __construct($data)
{
@@ -26,8 +25,6 @@ abstract class AbstractStructuredList extends \ArrayObject implements Restructur
abstract public function restructure(FormatterOptions $options);
abstract public function getListData(FormatterOptions $options);
protected function createTableTransformation($data, $options)
{
$defaults = $this->defaultOptions();

View File

@@ -0,0 +1,16 @@
<?php
namespace Consolidation\OutputFormatters\StructuredData;
use Consolidation\OutputFormatters\StructuredData\Xml\DomDataInterface;
class HelpDocument implements DomDataInterface
{
/**
* Convert data into a \DomDocument.
*
* @return \DomDocument
*/
public function getDomData()
{
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Consolidation\OutputFormatters\StructuredData;
use Consolidation\OutputFormatters\Options\FormatterOptions;
/**
* Represents aribtrary array data (structured or unstructured) where the
* data to display in --list format comes from the array keys.
*/
class ListDataFromKeys extends \ArrayObject implements ListDataInterface
{
public function __construct($data)
{
parent::__construct($data);
}
public function getListData(FormatterOptions $options)
{
return array_keys($this->getArrayCopy());
}
}

View File

@@ -44,7 +44,7 @@ class XmlSchema implements XmlSchemaInterface
protected function addXmlDataOrAttribute(\DOMDocument $dom, $xmlParent, $elementName, $key, $value)
{
$childElementName = $this->getDefaultElementName($elementName);
$elementName = is_numeric($key) ? $childElementName : $key;
$elementName = $this->determineElementName($key, $childElementName, $value);
if (($elementName != $childElementName) && $this->isAttribute($elementName, $key, $value)) {
$xmlParent->setAttribute($key, $value);
return;
@@ -52,6 +52,26 @@ class XmlSchema implements XmlSchemaInterface
$this->addXmlData($dom, $xmlParent, $elementName, $value);
}
protected function determineElementName($key, $childElementName, $value)
{
if (is_numeric($key)) {
return $childElementName;
}
if (is_object($value)) {
$value = (array)$value;
}
if (!is_array($value)) {
return $key;
}
if (array_key_exists('id', $value) && ($value['id'] == $key)) {
return $childElementName;
}
if (array_key_exists('name', $value) && ($value['name'] == $key)) {
return $childElementName;
}
return $key;
}
protected function getTopLevelElementName($structuredData)
{
return 'document';

View File

@@ -85,12 +85,13 @@ class DomToArraySimplifier implements SimplifyToArrayInterface
return [];
}
$uniformChildrenName = $this->hasUniformChildren($element);
if ("{$uniformChildrenName}s" == $element->nodeName) {
// Check for plurals.
if (in_array($element->nodeName, ["{$uniformChildrenName}s", "{$uniformChildrenName}es"])) {
$result = $this->getUniformChildren($element->nodeName, $element);
} else {
$result = $this->getUniqueChildren($element->nodeName, $element);
}
return $result;
return array_filter($result);
}
/**
@@ -153,7 +154,12 @@ class DomToArraySimplifier implements SimplifyToArrayInterface
if ($this->valueCanBeSimplified($value)) {
$value = array_shift($value);
}
$simplifiedChildren[$parentKey][] = $value;
$id = $this->getIdOfValue($value);
if ($id) {
$simplifiedChildren[$parentKey][$id] = $value;
} else {
$simplifiedChildren[$parentKey][] = $value;
}
}
return $simplifiedChildren;
}
@@ -178,6 +184,25 @@ class DomToArraySimplifier implements SimplifyToArrayInterface
return is_string($data);
}
/**
* If the object has an 'id' or 'name' element, then use that
* as the array key when storing this value in its parent.
* @param mixed $value
* @return string
*/
protected function getIdOfValue($value)
{
if (!is_array($value)) {
return false;
}
if (array_key_exists('id', $value)) {
return trim($value['id'], '-');
}
if (array_key_exists('name', $value)) {
return trim($value['name'], '-');
}
}
/**
* Convert the children of the provided DOM element into an array.
* Here, 'unique' means that all of the element names of the children are

View File

@@ -29,7 +29,9 @@ class PropertyParser
$lines = explode("\n", $data);
foreach ($lines as $line) {
list($key, $value) = explode(':', trim($line), 2) + ['', ''];
$result[$key] = trim($value);
if (!empty($key) && !empty($value)) {
$result[$key] = trim($value);
}
}
return $result;
}

View File

@@ -42,6 +42,9 @@ class ReorderFields
{
$result = [];
$firstRow = reset($data);
if (!$firstRow) {
$firstRow = $fieldLabels;
}
foreach ($fields as $field) {
if (array_key_exists($field, $firstRow)) {
if (array_key_exists($field, $fieldLabels)) {

View File

@@ -1,12 +1,14 @@
<?php
namespace Consolidation\OutputFormatters\Transformations;
use Consolidation\OutputFormatters\Transformations\Wrap\CalculateWidths;
use Consolidation\OutputFormatters\Transformations\Wrap\ColumnWidths;
use Symfony\Component\Console\Helper\TableStyle;
class WordWrapper
{
protected $width;
protected $minimumWidths = [];
protected $minimumWidths;
// For now, hardcode these to match what the Symfony Table helper does.
// Note that these might actually need to be adjusted depending on the
@@ -18,6 +20,7 @@ class WordWrapper
public function __construct($width)
{
$this->width = $width;
$this->minimumWidths = new ColumnWidths();
}
/**
@@ -40,7 +43,15 @@ class WordWrapper
*/
public function setMinimumWidths($minimumWidths)
{
$this->minimumWidths = $minimumWidths;
$this->minimumWidths = new ColumnWidths($minimumWidths);
}
/**
* Set the minimum width of just one column
*/
public function minimumWidth($colkey, $width)
{
$this->minimumWidths->setWidth($colkey, $width);
}
/**
@@ -50,25 +61,49 @@ class WordWrapper
*/
public function wrap($rows, $widths = [])
{
// If the width was not set, then disable wordwrap.
if (!$this->width) {
$auto_widths = $this->calculateWidths($rows, $widths);
// If no widths were provided, then disable wrapping
if ($auto_widths->isEmpty()) {
return $rows;
}
// Calculate the column widths to use based on the content.
$auto_widths = $this->columnAutowidth($rows, $widths);
// Do wordwrap on all cells.
$newrows = array();
foreach ($rows as $rowkey => $row) {
foreach ($row as $colkey => $cell) {
$newrows[$rowkey][$colkey] = $this->wrapCell($cell, $auto_widths[$colkey]);
$newrows[$rowkey][$colkey] = $this->wrapCell($cell, $auto_widths->width($colkey));
}
}
return $newrows;
}
/**
* Determine what widths we'll use for wrapping.
*/
protected function calculateWidths($rows, $widths = [])
{
// Widths must be provided in some form or another, or we won't wrap.
if (empty($widths) && !$this->width) {
return new ColumnWidths();
}
// Technically, `$widths`, if provided here, should be used
// as the exact widths to wrap to. For now we'll just treat
// these as minimum widths
$minimumWidths = $this->minimumWidths->combine(new ColumnWidths($widths));
$calculator = new CalculateWidths();
$dataCellWidths = $calculator->calculateLongestCell($rows);
$availableWidth = $this->width - $dataCellWidths->paddingSpace($this->paddingInEachCell, $this->extraPaddingAtEndOfLine, $this->extraPaddingAtBeginningOfLine);
$this->minimumWidths->adjustMinimumWidths($availableWidth, $dataCellWidths);
return $calculator->calculate($availableWidth, $dataCellWidths, $minimumWidths);
}
/**
* Wrap one cell. Guard against modifying non-strings and
* then call through to wordwrap().
@@ -84,144 +119,4 @@ class WordWrapper
}
return wordwrap($cell, $cellWidth, "\n", true);
}
/**
* Determine the best fit for column widths. Ported from Drush.
*
* @param array $rows The rows to use for calculations.
* @param array $widths Manually specified widths of each column
* (in characters) - these will be left as is.
*/
protected function columnAutowidth($rows, $widths)
{
$auto_widths = $widths;
// First we determine the distribution of row lengths in each column.
// This is an array of descending character length keys (i.e. starting at
// the rightmost character column), with the value indicating the number
// of rows where that character column is present.
$col_dist = [];
// We will also calculate the longest word in each column
$max_word_lens = [];
foreach ($rows as $rowkey => $row) {
foreach ($row as $col_id => $cell) {
$longest_word_len = static::longestWordLength($cell);
if ((!isset($max_word_lens[$col_id]) || ($max_word_lens[$col_id] < $longest_word_len))) {
$max_word_lens[$col_id] = $longest_word_len;
}
if (empty($widths[$col_id])) {
$length = strlen($cell);
if ($length == 0) {
$col_dist[$col_id][0] = 0;
}
while ($length > 0) {
if (!isset($col_dist[$col_id][$length])) {
$col_dist[$col_id][$length] = 0;
}
$col_dist[$col_id][$length]++;
$length--;
}
}
}
}
foreach ($col_dist as $col_id => $count) {
// Sort the distribution in decending key order.
krsort($col_dist[$col_id]);
// Initially we set all columns to their "ideal" longest width
// - i.e. the width of their longest column.
$auto_widths[$col_id] = max(array_keys($col_dist[$col_id]));
}
// We determine what width we have available to use, and what width the
// above "ideal" columns take up.
$available_width = $this->width - ($this->extraPaddingAtBeginningOfLine + $this->extraPaddingAtEndOfLine + (count($auto_widths) * $this->paddingInEachCell));
$auto_width_current = array_sum($auto_widths);
// If we cannot fit into the minimum width anyway, then just return
// the max word length of each column as the 'ideal'
$minimumIdealLength = array_sum($this->minimumWidths);
if ($minimumIdealLength && ($available_width < $minimumIdealLength)) {
return $max_word_lens;
}
// If we need to reduce a column so that we can fit the space we use this
// loop to figure out which column will cause the "least wrapping",
// (relative to the other columns) and reduce the width of that column.
while ($auto_width_current > $available_width) {
list($column, $width) = $this->selectColumnToReduce($col_dist, $auto_widths, $max_word_lens);
if (!$column || $width <= 1) {
// If we have reached a width of 1 then give up, so wordwrap can still progress.
break;
}
// Reduce the width of the selected column.
$auto_widths[$column]--;
// Reduce our overall table width counter.
$auto_width_current--;
// Remove the corresponding data from the disctribution, so next time
// around we use the data for the row to the left.
unset($col_dist[$column][$width]);
}
return $auto_widths;
}
protected function selectColumnToReduce($col_dist, $auto_widths, $max_word_lens)
{
$column = false;
$count = 0;
$width = 0;
foreach ($col_dist as $col_id => $counts) {
// Of the columns whose length is still > than the the lenght
// of their maximum word length
if ($auto_widths[$col_id] > $max_word_lens[$col_id]) {
if ($this->shouldSelectThisColumn($count, $counts, $width)) {
$column = $col_id;
$count = current($counts);
$width = key($counts);
}
}
}
if ($column !== false) {
return [$column, $width];
}
foreach ($col_dist as $col_id => $counts) {
if (empty($this->minimumWidths) || ($auto_widths[$col_id] > $this->minimumWidths[$col_id])) {
if ($this->shouldSelectThisColumn($count, $counts, $width)) {
$column = $col_id;
$count = current($counts);
$width = key($counts);
}
}
}
return [$column, $width];
}
protected function shouldSelectThisColumn($count, $counts, $width)
{
return
// If we are just starting out, select the first column.
($count == 0) ||
// OR: if this column would cause less wrapping than the currently
// selected column, then select it.
(current($counts) < $count) ||
// OR: if this column would cause the same amount of wrapping, but is
// longer, then we choose to wrap the longer column (proportionally
// less wrapping, and helps avoid triple line wraps).
(current($counts) == $count && key($counts) > $width);
}
/**
* Return the length of the longest word in the string.
* @param string $str
* @return int
*/
protected static function longestWordLength($str)
{
$words = preg_split('/[ -]/', $str);
$lengths = array_map(function ($s) {
return strlen($s);
}, $words);
return max($lengths);
}
}

View File

@@ -0,0 +1,141 @@
<?php
namespace Consolidation\OutputFormatters\Transformations\Wrap;
use Symfony\Component\Console\Helper\TableStyle;
/**
* Calculate column widths for table cells.
*
* Influenced by Drush and webmozart/console.
*/
class CalculateWidths
{
public function __construct()
{
}
/**
* Given the total amount of available space, and the width of
* the columns to place, calculate the optimum column widths to use.
*/
public function calculate($availableWidth, ColumnWidths $dataWidths, ColumnWidths $minimumWidths)
{
// First, check to see if all columns will fit at their full widths.
// If so, do no further calculations. (This may be redundant with
// the short column width calculation.)
if ($dataWidths->totalWidth() <= $availableWidth) {
return $dataWidths->enforceMinimums($minimumWidths);
}
// Get the short columns first. If there are none, then distribute all
// of the available width among the remaining columns.
$shortColWidths = $this->getShortColumns($availableWidth, $dataWidths, $minimumWidths);
if ($shortColWidths->isEmpty()) {
return $this->distributeLongColumns($availableWidth, $dataWidths, $minimumWidths);
}
// If some short columns were removed, then account for the length
// of the removed columns and make a recursive call (since the average
// width may be higher now, if the removed columns were shorter in
// length than the previous average).
$availableWidth -= $shortColWidths->totalWidth();
$remainingWidths = $dataWidths->removeColumns($shortColWidths->keys());
$remainingColWidths = $this->calculate($availableWidth, $remainingWidths, $minimumWidths);
return $shortColWidths->combine($remainingColWidths);
}
/**
* Calculate the longest cell data from any row of each of the cells.
*/
public function calculateLongestCell($rows)
{
return $this->calculateColumnWidths(
$rows,
function ($cell) {
return strlen($cell);
}
);
}
/**
* Calculate the longest word and longest line in the provided data.
*/
public function calculateLongestWord($rows)
{
return $this->calculateColumnWidths(
$rows,
function ($cell) {
return static::longestWordLength($cell);
}
);
}
protected function calculateColumnWidths($rows, callable $fn)
{
$widths = [];
// Examine each row and find the longest line length and longest
// word in each column.
foreach ($rows as $rowkey => $row) {
foreach ($row as $colkey => $cell) {
$value = $fn($cell);
if ((!isset($widths[$colkey]) || ($widths[$colkey] < $value))) {
$widths[$colkey] = $value;
}
}
}
return new ColumnWidths($widths);
}
/**
* Return all of the columns whose longest line length is less than or
* equal to the average width.
*/
public function getShortColumns($availableWidth, ColumnWidths $dataWidths, ColumnWidths $minimumWidths)
{
$averageWidth = $dataWidths->averageWidth($availableWidth);
$shortColWidths = $dataWidths->findShortColumns($averageWidth);
return $shortColWidths->enforceMinimums($minimumWidths);
}
/**
* Distribute the remainig space among the columns that were not
* included in the list of "short" columns.
*/
public function distributeLongColumns($availableWidth, ColumnWidths $dataWidths, ColumnWidths $minimumWidths)
{
// First distribute the remainder without regard to the minimum widths.
$result = $dataWidths->distribute($availableWidth);
// Find columns that are shorter than their minimum width.
$undersized = $result->findUndersizedColumns($minimumWidths);
// Nothing too small? Great, we're done!
if ($undersized->isEmpty()) {
return $result;
}
// Take out the columns that are too small and redistribute the rest.
$availableWidth -= $undersized->totalWidth();
$remaining = $dataWidths->removeColumns($undersized->keys());
$distributeRemaining = $this->distributeLongColumns($availableWidth, $remaining, $minimumWidths);
return $undersized->combine($distributeRemaining);
}
/**
* Return the length of the longest word in the string.
* @param string $str
* @return int
*/
protected static function longestWordLength($str)
{
$words = preg_split('#[ /-]#', $str);
$lengths = array_map(function ($s) {
return strlen($s);
}, $words);
return max($lengths);
}
}

View File

@@ -0,0 +1,264 @@
<?php
namespace Consolidation\OutputFormatters\Transformations\Wrap;
use Symfony\Component\Console\Helper\TableStyle;
/**
* Calculate the width of data in table cells in preparation for word wrapping.
*/
class ColumnWidths
{
protected $widths;
public function __construct($widths = [])
{
$this->widths = $widths;
}
public function paddingSpace(
$paddingInEachCell,
$extraPaddingAtEndOfLine = 0,
$extraPaddingAtBeginningOfLine = 0
) {
return ($extraPaddingAtBeginningOfLine + $extraPaddingAtEndOfLine + (count($this->widths) * $paddingInEachCell));
}
/**
* Find all of the columns that are shorter than the specified threshold.
*/
public function findShortColumns($thresholdWidth)
{
$thresholdWidths = array_fill_keys(array_keys($this->widths), $thresholdWidth);
return $this->findColumnsUnderThreshold($thresholdWidths);
}
/**
* Find all of the columns that are shorter than the corresponding minimum widths.
*/
public function findUndersizedColumns($minimumWidths)
{
return $this->findColumnsUnderThreshold($minimumWidths->widths());
}
protected function findColumnsUnderThreshold(array $thresholdWidths)
{
$shortColWidths = [];
foreach ($this->widths as $key => $maxLength) {
if (isset($thresholdWidths[$key]) && ($maxLength <= $thresholdWidths[$key])) {
$shortColWidths[$key] = $maxLength;
}
}
return new ColumnWidths($shortColWidths);
}
/**
* If the widths specified by this object do not fit within the
* provided avaiable width, then reduce them all proportionally.
*/
public function adjustMinimumWidths($availableWidth, $dataCellWidths)
{
$result = $this->selectColumns($dataCellWidths->keys());
if ($result->isEmpty()) {
return $result;
}
$numberOfColumns = $dataCellWidths->count();
// How many unspecified columns are there?
$unspecifiedColumns = $numberOfColumns - $result->count();
$averageWidth = $this->averageWidth($availableWidth);
// Reserve some space for the columns that have no minimum.
// Make sure they collectively get at least half of the average
// width for each column. Or should it be a quarter?
$reservedSpacePerColumn = ($averageWidth / 2);
$reservedSpace = $reservedSpacePerColumn * $unspecifiedColumns;
// Calculate how much of the available space is remaining for use by
// the minimum column widths after the reserved space is accounted for.
$remainingAvailable = $availableWidth - $reservedSpace;
// Don't do anything if our widths fit inside the available widths.
if ($result->totalWidth() <= $remainingAvailable) {
return $result;
}
// Shrink the minimum widths if the table is too compressed.
return $result->distribute($remainingAvailable);
}
/**
* Return proportional weights
*/
public function distribute($availableWidth)
{
$result = [];
$totalWidth = $this->totalWidth();
$lastColumn = $this->lastColumn();
$widths = $this->widths();
// Take off the last column, and calculate proportional weights
// for the first N-1 columns.
array_pop($widths);
foreach ($widths as $key => $width) {
$result[$key] = round(($width / $totalWidth) * $availableWidth);
}
// Give the last column the rest of the available width
$usedWidth = $this->sumWidth($result);
$result[$lastColumn] = $availableWidth - $usedWidth;
return new ColumnWidths($result);
}
public function lastColumn()
{
$keys = $this->keys();
return array_pop($keys);
}
/**
* Return the number of columns.
*/
public function count()
{
return count($this->widths);
}
/**
* Calculate how much space is available on average for all columns.
*/
public function averageWidth($availableWidth)
{
if ($this->isEmpty()) {
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
}
return $availableWidth / $this->count();
}
/**
* Return the available keys (column identifiers) from the calculated
* data set.
*/
public function keys()
{
return array_keys($this->widths);
}
/**
* Set the length of the specified column.
*/
public function setWidth($key, $width)
{
$this->widths[$key] = $width;
}
/**
* Return the length of the specified column.
*/
public function width($key)
{
return isset($this->widths[$key]) ? $this->widths[$key] : 0;
}
/**
* Return all of the lengths
*/
public function widths()
{
return $this->widths;
}
/**
* Return true if there is no data in this object
*/
public function isEmpty()
{
return empty($this->widths);
}
/**
* Return the sum of the lengths of the provided widths.
*/
public function totalWidth()
{
return static::sumWidth($this->widths());
}
/**
* Return the sum of the lengths of the provided widths.
*/
public static function sumWidth($widths)
{
return array_reduce(
$widths,
function ($carry, $item) {
return $carry + $item;
}
);
}
/**
* Ensure that every item in $widths that has a corresponding entry
* in $minimumWidths is as least as large as the minimum value held there.
*/
public function enforceMinimums($minimumWidths)
{
$result = [];
if ($minimumWidths instanceof ColumnWidths) {
$minimumWidths = $minimumWidths->widths();
}
$minimumWidths += $this->widths;
foreach ($this->widths as $key => $value) {
$result[$key] = max($value, $minimumWidths[$key]);
}
return new ColumnWidths($result);
}
/**
* Remove all of the specified columns from this data structure.
*/
public function removeColumns($columnKeys)
{
$widths = $this->widths();
foreach ($columnKeys as $key) {
unset($widths[$key]);
}
return new ColumnWidths($widths);
}
/**
* Select all columns that exist in the provided list of keys.
*/
public function selectColumns($columnKeys)
{
$widths = [];
foreach ($columnKeys as $key) {
if (isset($this->widths[$key])) {
$widths[$key] = $this->width($key);
}
}
return new ColumnWidths($widths);
}
/**
* Combine this set of widths with another set, and return
* a new set that contains the entries from both.
*/
public function combine(ColumnWidths $combineWith)
{
// Danger: array_merge renumbers numeric keys; that must not happen here.
$combined = $combineWith->widths();
foreach ($this->widths() as $key => $value) {
$combined[$key] = $value;
}
return new ColumnWidths($combined);
}
}

View File

@@ -0,0 +1,20 @@
<?php
use Consolidation\OutputFormatters\Transformations\WordWrapper;
include 'vendor/autoload.php';
$wrapper = new WordWrapper(78);
$data = [
'name' => ['Name', ':', 'Rex', ],
'species' => ['Species', ':', 'dog', ],
'food' => ['Food', ':', 'kibble', ],
'legs' => ['Legs', ':', '4', ],
'description' => ['Description', ':', 'Rex is a very good dog, Brett. He likes kibble, and has four legs.', ],
];
$result = $wrapper->wrap($data);
var_export($result);

View File

@@ -18,7 +18,7 @@ class APIDocsTests extends \PHPUnit_Framework_TestCase
}
$testDocs = tempnam(sys_get_temp_dir(), 'TestAPIDocs.md');
$currentDocs = getcwd() . '/docs/Api.md';
$currentDocs = getcwd() . '/docs/api.md';
passthru("vendor/bin/phpdoc-md generate src > $testDocs");
$testDocsContent = file_get_contents($testDocs);
@@ -27,6 +27,6 @@ class APIDocsTests extends \PHPUnit_Framework_TestCase
$testDocsContent = str_replace (array("\r\n", "\r"), "\n", $testDocsContent);
$currentDocsContent = str_replace (array("\r\n", "\r"), "\n", $currentDocsContent);
$this->assertEquals($testDocsContent, $currentDocsContent, "API docuementation out of date. Run 'composer Api' to update.");
$this->assertEquals($testDocsContent, $currentDocsContent, "API docuementation out of date. Run 'composer api' to update.");
}
}

View File

@@ -7,6 +7,7 @@ use Consolidation\OutputFormatters\Options\FormatterOptions;
use Consolidation\OutputFormatters\StructuredData\AssociativeList;
use Consolidation\OutputFormatters\StructuredData\RowsOfFields;
use Consolidation\OutputFormatters\StructuredData\PropertyList;
use Consolidation\OutputFormatters\StructuredData\ListDataFromKeys;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputInterface;
@@ -47,8 +48,31 @@ one: a
two: b
three: c
EOT;
$this->assertFormattedOutputMatches($expected, 'yaml', $data);
$expected = <<<EOT
a
b
c
EOT;
$this->assertFormattedOutputMatches($expected, 'list', $data);
$data = new ListDataFromKeys($data);
$expected = <<<EOT
one: a
two: b
three: c
EOT;
$this->assertFormattedOutputMatches($expected, 'yaml', $data);
$expected = <<<EOT
one
two
three
EOT;
$this->assertFormattedOutputMatches($expected, 'list', $data);
}
function testNestedYaml()
@@ -527,7 +551,6 @@ EOT;
function testTableWithWordWrapping()
{
$options = new FormatterOptions();
$options->setWidth(42);
$data = [
[
@@ -538,19 +561,191 @@ EOT;
$data = new RowsOfFields($data);
$expected = <<<EOT
------------------- --------------------
First Second
------------------- --------------------
This is a really This is the second
long cell that column of the same
contains a lot of table. It is also
data. When it is very long, and
rendered, it should be wrapped
should be wrapped across multiple
across multiple lines, just like
lines. the first column.
------------------- --------------------
------------------ --------------------
First Second
------------------ --------------------
This is a really This is the second
long cell that column of the same
contains a lot table. It is also
of data. When it very long, and
is rendered, it should be wrapped
should be across multiple
wrapped across lines, just like
multiple lines. the first column.
------------------ --------------------
EOT;
$options->setWidth(42);
$this->assertFormattedOutputMatches($expected, 'table', $data, $options);
$expected = <<<EOT
----------------------------------- ---------------------------------------
First Second
----------------------------------- ---------------------------------------
This is a really long cell that This is the second column of the same
contains a lot of data. When it table. It is also very long, and
is rendered, it should be wrapped should be wrapped across multiple
across multiple lines. lines, just like the first column.
----------------------------------- ---------------------------------------
EOT;
$options->setWidth(78);
$this->assertFormattedOutputMatches($expected, 'table', $data, $options);
}
function testWrappingLotsOfColumns()
{
$options = new FormatterOptions();
$data = [
[
'id' => '4d87b545-b4c3-4ece-9908-20c5c5e67e81',
'name' => '123456781234567812345678123456781234567812345678',
'service_level' => 'business',
'framework' => 'wordpress-network',
'owner' => '8558a08d-8059-45f6-9c4b-908299a025ee',
'created' => '2017-05-24 19:28:45',
'memberships' => 'b3a42ba5-755d-42ca-9109-21bde32809d0: Team,9bfaaf50-ece3-4460-acb8-dc1b8dd536e8: pantheon-engineering-canary-sites',
'frozen' => 'false',
],
[
'id' => '3d87b545-b4c3-4ece-9908-20c5c5e67e80',
'name' => 'build-tools-136',
'service_level' => 'free',
'framework' => 'drupal8',
'owner' => '7558a08d-8059-45f6-9c4b-908299a025ef',
'created' => '2017-05-24 19:28:45',
'memberships' => '5ae1fa30-8cc4-4894-8ca9-d50628dcba17: ci-for-drupal-8-composer',
'frozen' => 'false',
]
];
$data = new RowsOfFields($data);
$expected = <<<EOT
------------- ---------------- --------------- ----------- ------------- --------- ------------------------------------ --------
Id Name Service_level Framework Owner Created Memberships Frozen
------------- ---------------- --------------- ----------- ------------- --------- ------------------------------------ --------
4d87b545-b4 12345678123456 business wordp 8558a08d-80 2017-0 b3a42ba5-755d-42ca-9109-21bde32809 false
c3-4ece-990 78123456781234 ress- 59-45f6-9c4 5-24 d0:
8-20c5c5e67 56781234567812 netwo b-908299a02 19:28: Team,9bfaaf50-ece3-4460-acb8-dc1b8
e81 345678 rk 5ee 45 dd536e8:
pantheon-engineering-canary-sites
3d87b545-b4 build-tools-13 free drupa 7558a08d-80 2017-0 5ae1fa30-8cc4-4894-8ca9-d50628dcba false
c3-4ece-990 6 l8 59-45f6-9c4 5-24 17: ci-for-drupal-8-composer
8-20c5c5e67 b-908299a02 19:28:
e80 5ef 45
------------- ---------------- --------------- ----------- ------------- --------- ------------------------------------ --------
EOT;
$options->setWidth(125);
$this->assertFormattedOutputMatches($expected, 'table', $data, $options);
}
function testTableWithWordWrapping2()
{
$options = new FormatterOptions();
$data = [
[
'id' => 42,
'vid' => 321,
'description' => 'Life, the Universe and Everything.',
],
[
'id' => 13,
'vid' => 789,
'description' => 'Why is six afraid of seven?',
],
];
$data = new RowsOfFields($data);
$expected = <<<EOT
---- ----- -----------------------------
Id Vid Description
---- ----- -----------------------------
42 321 Life, the Universe and
Everything.
13 789 Why is six afraid of seven?
---- ----- -----------------------------
EOT;
$options->setWidth(42);
$this->assertFormattedOutputMatches($expected, 'table', $data, $options);
}
function testTableWithWordWrapping3()
{
$options = new FormatterOptions();
$data = [
'name' => 'Rex',
'species' => 'dog',
'food' => 'kibble',
'legs' => '4',
'description' => 'Rex is a very good dog, Brett. He likes kibble, and has four legs.',
];
$data = new PropertyList($data);
$expected = <<<EOT
------------- -------------------------
Name Rex
Species dog
Food kibble
Legs 4
Description Rex is a very good dog,
Brett. He likes kibble,
and has four legs.
------------- -------------------------
EOT;
$options->setWidth(42);
$this->assertFormattedOutputMatches($expected, 'table', $data, $options);
}
function testTableWithWordWrapping4()
{
$options = new FormatterOptions();
$data = [
'name' => ['label' => 'Name', 'sep' => ':', 'value' => 'Rex', ],
'species' => ['label' => 'Species', 'sep' => ':', 'value' => 'dog', ],
'food' => ['label' => 'Food', 'sep' => ':', 'value' => 'kibble', ],
'legs' => ['label' => 'Legs', 'sep' => ':', 'value' => '4', ],
'description' => ['label' => 'Description', 'sep' => ':', 'value' => 'Rex is a very good dog, Brett. He likes kibble, and has four legs.', ],
];
$data = new RowsOfFields($data);
$expected = <<<EOT
------------- ----- -----------------------------------------------------
Label Sep Value
------------- ----- -----------------------------------------------------
Name : Rex
Species : dog
Food : kibble
Legs : 4
Description : Rex is a very good dog, Brett. He likes kibble, and
has four legs.
------------- ----- -----------------------------------------------------
EOT;
$options->setWidth(78);
$this->assertFormattedOutputMatches($expected, 'table', $data, $options);
}
function testTableWithWordWrapping5()
{
$options = new FormatterOptions();
$data = [
'name' => ['Name', ':', 'Rex', ],
'species' => ['Species', ':', 'dog', ],
'food' => ['Food', ':', 'kibble', ],
'legs' => ['Legs', ':', '4', ],
'description' => ['Description', ':', 'Rex is a very good dog, Brett. He likes kibble, and has four legs.', ],
];
$data = new RowsOfFields($data);
$expected = <<<EOT
Name : Rex
Species : dog
Food : kibble
Legs : 4
Description : Rex is a very good dog, Brett. He likes kibble, and has
four legs.
EOT;
$options->setWidth(78);
$options->setIncludeFieldLables(false);
$options->setTableStyle('compact');
$this->assertFormattedOutputMatches($expected, 'table', $data, $options);
}
@@ -842,6 +1037,17 @@ EOT;
-----
EOT;
$this->assertFormattedOutputMatches($expectedSingleField, 'table', $data, $configurationData, ['field' => 'San']);
$expectedEmptyColumn = <<<EOT
-----
San
-----
EOT;
$this->assertFormattedOutputMatches($expectedEmptyColumn, 'table', new RowsOfFields([]), $configurationData, ['field' => 'San']);
$this->assertFormattedOutputMatches('', '', new RowsOfFields([]), $configurationData, ['field' => 'San']);
$this->assertFormattedOutputMatches('[]', 'json', new RowsOfFields([]), $configurationData, ['field' => 'San']);
}
/**
@@ -941,6 +1147,20 @@ EOT;
->setFieldLabels(['one' => 'I', 'two' => 'II', 'three' => 'III']);
$this->assertFormattedOutputMatches($expected, 'table', $data, $formatterOptionsWithFieldLables);
$expectedDrushStyleTable = <<<EOT
One : apple
Two : banana
Three : carrot
EOT;
// If we provide field labels, then the output will change to reflect that.
$formatterOptionsWithFieldLables = new FormatterOptions();
$formatterOptionsWithFieldLables
->setTableStyle('compact')
->setListDelimiter(':');
$this->assertFormattedOutputMatches($expectedDrushStyleTable, 'table', $data, $formatterOptionsWithFieldLables);
// Adding an extra field that does not exist in the data set should not change the output
$formatterOptionsWithExtraFieldLables = new FormatterOptions();
$formatterOptionsWithExtraFieldLables
@@ -1261,8 +1481,8 @@ EOT;
{
"name": "widget-collection",
"description": "A couple of widgets.",
"widgets": [
{
"widgets": {
"usual": {
"name": "usual",
"colors": [
"red",
@@ -1275,7 +1495,7 @@ EOT;
"triangle"
]
},
{
"unusual": {
"name": "unusual",
"colors": [
"muave",
@@ -1288,7 +1508,7 @@ EOT;
"trapazoid"
]
}
]
}
}
EOT;