PHP Класс Piwik\DataTable\Row

DataTable rows contain columns, metadata and a subtable ID. Columns and metadata are stored as an array of name => value mappings.
Наследование: implements ArrayAccess, implements IteratorAggregate
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$maxVisitsSummed @see sumRow - implementation detail
$subtableId

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

Метод Описание
__construct ( array $row = [] ) Constructor.
__destruct ( ) When destroyed, a row destroys its associated subtable if there is one.
__toString ( ) : string Applies a basic rendering to the Row and returns the output.
addColumn ( string $name, mixed $value ) Add a new column to the row. If the column already exists, throws an exception.
addColumns ( array $columns ) : void Add many columns to this row.
addMetadata ( string $name, mixed $value ) Add a new metadata to the row. If the metadata already exists, throws an exception.
compareElements ( mixed $elem1, mixed $elem2 ) : boolean Helper function to compare array elements
deleteColumn ( string $name ) : boolean Deletes the given column.
deleteMetadata ( boolean | string $name = false ) : boolean Deletes one metadata value or all metadata values.
export ( ) : array Used when archiving to serialize the Row's properties.
getColumn ( string $name ) : mixed | false Returns a column by name.
getColumns ( ) : array Returns the array containing all the columns.
getIdSubDataTable ( ) : integer | null Returns the ID of the subDataTable.
getMetadata ( string | null $name = null ) : mixed Returns the array of all metadata, or one requested metadata value.
getSubtable ( ) : DataTable | boolean Returns the associated subtable, if one exists. Returns false if none exists.
hasColumn ( string $name ) : boolean Returns true if a column having the given name is already registered. The value will not be evaluated, it will just check whether a column exists independent of its value.
isEqual ( Row $row1, Row $row2 ) : boolean Helper function that tests if two rows are equal.
isSubtableLoaded ( ) : boolean Returns true if the subtable is currently loaded in memory via {@link Piwik\DataTable\Manager}.
isSummaryRow ( ) : boolean Returns true if this row is the summary row, false if otherwise. This function depends on the label of the row, and so, is not 100% accurate.
removeSubtable ( ) Removes the subtable reference.
renameColumn ( string $oldName, string $newName ) Renames a column.
setColumn ( string $name, mixed $value ) Set the value $value to the column called $name.
setColumns ( array $columns ) Set all the columns at once. Overwrites **all** previously set columns.
setMetadata ( string $name, mixed $value ) Set the value $value to the metadata called $name.
setNonLoadedSubtableId ( integer $subtableId )
setSubtable ( DataTable $subTable ) : DataTable Attaches a subtable to this row, overwriting the existing subtable, if any.
sumRow ( Row $rowToSum, boolean $enableCopyMetadata = true, array | boolean $aggregationOperations = false ) Sums the given $rowToSum columns values to the existing row column values.
sumRowMetadata ( Row $rowToSum, array $aggregationOperations = [] ) Sums the metadata in $rowToSum with the metadata in $this row.
sumSubtable ( DataTable $subTable ) Sums a DataTable to this row's subtable. If this row has no subtable a new one is created.

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

Метод Описание
sumRowArray ( number | boolean $thisColumnValue, number | array $columnToSumValue ) : array | integer Helper function: sums 2 values
warnWhenSummingTwoStrings ( $thisColumnValue, $columnToSumValue )

Приватные методы

Метод Описание
getColumnValuesMerged ( $operation, $thisColumnValue, $columnToSumValue, $thisRow, $rowToSum )
isSummableColumn ( $columnName )
warnIfSubtableAlreadyExists ( )

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

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

Constructor.
public __construct ( array $row = [] )
$row array An array with the following structure: array( Row::COLUMNS => array('label' => 'Piwik', 'column1' => 42, 'visits' => 657, 'time_spent' => 155744), Row::METADATA => array('logo' => 'test.png'), Row::DATATABLE_ASSOCIATED => $subtable // DataTable object // (but in the row only the ID will be stored) )

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

When destroyed, a row destroys its associated subtable if there is one.
public __destruct ( )

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

Applies a basic rendering to the Row and returns the output.
public __toString ( ) : string
Результат string describing the row. Example: "- 1 ['label' => 'piwik', 'nb_uniq_visitors' => 1685, 'nb_visits' => 1861] [] [idsubtable = 1375]"

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

Add a new column to the row. If the column already exists, throws an exception.
public addColumn ( string $name, mixed $value )
$name string name of the column to add.
$value mixed value of the column to set or a PHP callable.

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

Add many columns to this row.
public addColumns ( array $columns ) : void
$columns array Name/Value pairs, e.g., `array('name' => $value , ...)`
Результат void

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

Add a new metadata to the row. If the metadata already exists, throws an exception.
public addMetadata ( string $name, mixed $value )
$name string name of the metadata to add.
$value mixed value of the metadata to set.

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

Helper function to compare array elements
public static compareElements ( mixed $elem1, mixed $elem2 ) : boolean
$elem1 mixed
$elem2 mixed
Результат boolean

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

Deletes the given column.
public deleteColumn ( string $name ) : boolean
$name string The column name.
Результат boolean `true` on success, `false` if the column does not exist.

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

Deletes one metadata value or all metadata values.
public deleteMetadata ( boolean | string $name = false ) : boolean
$name boolean | string Metadata name (omit to delete entire metadata).
Результат boolean `true` on success, `false` if the column didn't exist

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

Used when archiving to serialize the Row's properties.
public export ( ) : array
Результат array

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

Returns a column by name.
public getColumn ( string $name ) : mixed | false
$name string The column name.
Результат mixed | false The column value or false if it doesn't exist.

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

Returns the array containing all the columns.
public getColumns ( ) : array
Результат array Example: array( 'column1' => VALUE, 'label' => 'www.php.net' 'nb_visits' => 15894, )

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

If there is no such a table, returns null.
public getIdSubDataTable ( ) : integer | null
Результат integer | null

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

Returns the array of all metadata, or one requested metadata value.
public getMetadata ( string | null $name = null ) : mixed
$name string | null The name of the metadata to return or null to return all metadata.
Результат mixed

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

Returns the associated subtable, if one exists. Returns false if none exists.
public getSubtable ( ) : DataTable | boolean
Результат Piwik\DataTable | boolean

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

Returns true if a column having the given name is already registered. The value will not be evaluated, it will just check whether a column exists independent of its value.
public hasColumn ( string $name ) : boolean
$name string
Результат boolean

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

Two rows are equal if: - they have exactly the same columns / metadata - they have a subDataTable associated, then we check that both of them are the same. Column order is not important.
public static isEqual ( Row $row1, Row $row2 ) : boolean
$row1 Row first to compare
$row2 Row second to compare
Результат boolean

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

Returns true if the subtable is currently loaded in memory via {@link Piwik\DataTable\Manager}.
public isSubtableLoaded ( ) : boolean
Результат boolean

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

Returns true if this row is the summary row, false if otherwise. This function depends on the label of the row, and so, is not 100% accurate.
public isSummaryRow ( ) : boolean
Результат boolean

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

Removes the subtable reference.
public removeSubtable ( )

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

Renames a column.
public renameColumn ( string $oldName, string $newName )
$oldName string The current name of the column.
$newName string The new name of the column.

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

Set the value $value to the column called $name.
public setColumn ( string $name, mixed $value )
$name string name of the column to set.
$value mixed value of the column to set.

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

Set all the columns at once. Overwrites **all** previously set columns.
public setColumns ( array $columns )
$columns array eg, `array('label' => 'www.php.net', 'nb_visits' => 15894)`

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

Set the value $value to the metadata called $name.
public setMetadata ( string $name, mixed $value )
$name string name of the metadata to set.
$value mixed value of the metadata to set.

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

public setNonLoadedSubtableId ( integer $subtableId )
$subtableId integer

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

Attaches a subtable to this row, overwriting the existing subtable, if any.
public setSubtable ( DataTable $subTable ) : DataTable
$subTable Piwik\DataTable DataTable to associate to this row.
Результат Piwik\DataTable Returns `$subTable`.

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

Only the int or float values will be summed. Label columns will be ignored even if they have a numeric value. Columns in $rowToSum that don't exist in $this are added to $this.
public sumRow ( Row $rowToSum, boolean $enableCopyMetadata = true, array | boolean $aggregationOperations = false )
$rowToSum Row The row to sum to this row.
$enableCopyMetadata boolean Whether metadata should be copied or not.
$aggregationOperations array | boolean for columns that should not be summed, determine which aggregation should be used (min, max). format: `array('column name' => 'function name')`

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

Helper function: sums 2 values
protected sumRowArray ( number | boolean $thisColumnValue, number | array $columnToSumValue ) : array | integer
$thisColumnValue number | boolean
$columnToSumValue number | array
Результат array | integer

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

Sums the metadata in $rowToSum with the metadata in $this row.
public sumRowMetadata ( Row $rowToSum, array $aggregationOperations = [] )
$rowToSum Row
$aggregationOperations array

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

See {@link Piwik\DataTable::addDataTable()} to learn how DataTables are summed.
public sumSubtable ( DataTable $subTable )
$subTable Piwik\DataTable Table to sum to this row's subtable.

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

protected warnWhenSummingTwoStrings ( $thisColumnValue, $columnToSumValue )

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

$maxVisitsSummed публичное свойство

@see sumRow - implementation detail
public $maxVisitsSummed

$subtableId публичное свойство

public $subtableId