Use SMW\TableFormatter for the table query printer (SMWTableResultPrinter)

Authored by mwjames.


Use SMW\TableFormatter for the table query printer (SMWTableResultPrinter)

SMWTableResultPrinter has a CRAP of 478 which puts this printer into
a category of a potential hazardous printer that can be broken easily.

Doing data gathering and doing formatting are fundamentally two
different things and should not be mixed as it increases complexity.
Having attributes being dependent on data they present is necessary
but HTML related formatting has nothing to do with the data itself
therefore it is the wrong place and a formatting class should be used

It doesn't solve the inherent problem of the SMWTableResultPrinter class
but it allows for seperate unit testing and coverage.

Code overage: 100%
CRAP: 25

Code coverage: 33.33%
CRAP: before 478 after 352

$tableFormatter = new SMW\TableFormatter();

// Setup the header
$tableFormatter->addTableHeader( 'Foo' )
$tableFormatter->addTableHeader( 'Bar' )

// Add row
$tableFormatter->addTableCell( 'Lula' )
$tableFormatter->addTableCell( 'Lala' )

Get table
Standard table
$tableFormatter->transpose()->getTable() Transposed table
$tableFormatter->transpose( false )->getTable()
Standard table


SMW\TableFormatter is used for the Factbox as well.

[1] http://www.semantic-mediawiki.org/wiki/CRAP

Change-Id: I11c0057669e0a18c7b573ef64b21414fcb202b01