Skip to main content

Table

Helper for rendering tables


Constants

ConstantVisibilityTypeValue
TABLE_HEADpublicstring'thead'
TABLE_BODYpublicstring'tbody'
TABLE_FOOTERpublic'tfoot'
TABLE_ROWpublic'tr'
TABLE_Hpublicstring'th'
TABLE_DATApublicstring'td'

Properties

allowedAlignments

protected static $allowedAlignments
  • This property is static.

Methods

__invoke

Generates a 'table' element

public __invoke(array $rows, array $attributes = [], bool $escape = true): string

Parameters:

ParameterTypeDescription
$rowsarraytable rows
$attributesarrayhtml attributes of the "<table>" element.
Default : empty
$escapebooltrue espace html content of cells. Default True

Return Value:

The table XHTML.

Throws:

  • InvalidArgumentException

renderTableRows

Generate table rows elements

protected renderTableRows(array $rows, bool $escape = true): string

Parameters:

ParameterTypeDescription
$rowsarraythe array of rows.
$escapebooltrue espace html content of cells. Default True

Return Value:

The rows XHTML.

Throws:

  • InvalidArgumentException

renderTableCation

protected renderTableCation(mixed $caption, bool $escape = true): string

Parameters:

ParameterTypeDescription
$captionmixed
$escapebool

renderTableGroupRows

Generate table group rows elements

protected renderTableGroupRows(string $groupType, array $groupRows, bool $escape = true): string

Parameters:

ParameterTypeDescription
$groupTypestringthe row group type to be rendered.
Can be TABLE_HEAD, TABLE_BODY or TABLE_FOOTER
$groupRowsarraythe rows to be rendered
$escapebooltrue espace html content of cells. Default True

Return Value:

The grouped rows XHTML.

Throws:

  • InvalidArgumentException

renderTableRow

Generate table row element "<tr>"

protected renderTableRow(array $row, string $defaultCellType = null, bool $escape = true): string

Parameters:

ParameterTypeDescription
$rowarraythe array of cells.
$defaultCellTypestringthe default cell element
(th or td) to be used
$escapebooltrue espace html content of cells. Default True

Return Value:

The row XHTML.


renderTableCell

Generate table cell element "<th>" or "<td>"

public renderTableCell(int|float|string|bool|array $cell, string|null $defaultCellType = null, bool $isFirstCol = true, bool $escape = true): string

Parameters:

ParameterTypeDescription
$cellint|float|string|bool|arraythe cell data
$defaultCellTypestring|nullthe default cell element
(th or td) to be used
$isFirstColboolweither the given cell is the first cell in the row
$escapebooltrue espace html content of cells. Default True

Return Value:

The cell XHTML.

Throws:

  • InvalidArgumentException

defineCellStructure

protected defineCellStructure(mixed $cell, ?string $defaultCellType = null, bool $isFirstCol = true): array

Parameters:

ParameterTypeDescription
$cellmixed
$defaultCellType?string
$isFirstColbool

getAlignmentClass

protected getAlignmentClass(string $alignment): string

Parameters:

ParameterTypeDescription
$alignmentstring