CSVObject

Extends\org\turbocommons\src\main\php\model\TableObject

CSV data abstraction

package

Default

Methods

TableObject is an abstraction of a 2D table with X columns and Y rows where each cell can be used to store any kind of data.

__construct(integer $rows,mixed $columns): \org\turbocommons\src\main\php\model\TableObject
inherited

Columns can be labeled with a textual name which can be used to access them anytime (data can be also accessed via numeric row and column indexes).

Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$rows

integer

The number of rows for the created table (Rows can be added or modified anytime later).

$columns

mixed

The number of columns to create or an array of strings containing the column labels for all of the columns that will be created (Columns can be added or modified anytime later).

Response

\org\turbocommons\src\main\php\model\TableObject

The constructed TableObject

Add the specified amount of columns to the table.

addColumns(integer $number,array $names = array(),integer $at = -1): boolean
inherited
Throws
\UnexpectedValueException

Arguments

$number

integer

The number of columns that will be added to the table

$names

array

Optionally we can list all the labels to define for the new columns that will be added

$at

integer

Defines the column index where the new columns will be inserted. Old columns that are located at the insertion point will not be deleted, they will be moved to the Right. By default all the new columns will be appended at the end of the table unless a positive value is specified here.

Response

boolean

True if the operation was successful

Add the specified amount of rows to the table.

addRows(integer $number,integer $at = -1): boolean
inherited
Throws
\UnexpectedValueException

Arguments

$number

integer

The number of rows that will be added to the table

$at

integer

Defines the row index where the new rows will be inserted. Old rows that are located at the insertion point will not be deleted, they will be moved down. By default all the new rows will be appended at the bottom of the table unless a positive value is specified here.

Response

boolean

True if the operation was successful

Get the total number of cells that are currently available on this table

countCells(): integer
inherited
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Response

integer

The total number of cells on the table

Get the total number of columns that are currently available on this table

countColumns(): integer
inherited
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Response

integer

The total number of columns on the table

Get the total number of rows that are currently available on this table

countRows(): integer
inherited
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Response

integer

The total number of rows on the table

Get the value contained at the specified table cell

getCell(integer $row,mixed $column): mixed
inherited
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$row

integer

An integer containing the index for the row that we want to retrieve

$column

mixed

An integer or a string containing the index or label for the column that we want to retrieve

Response

mixed

The value for the cell that is located at the specified row and column

Get all the elements that are located at the specified column index or label.

getColumn(mixed $column): array
inherited
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$column

mixed

An integer or a string containing the index or label for the column that we want to retrieve

Response

array

All the table elements that belong to the required column

Get the numeric column index from it's label

getColumnIndex(string $name): integer
inherited
Throws
\UnexpectedValueException

Arguments

$name

string

The label for an existing column

Response

integer

The numeric index that is related to the given column label

Get the defined column name for a given column index

getColumnName(integer $columnIndex): string
inherited
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$columnIndex

integer

a numeric column index

Response

string

The column label for the specified numeric index

Get a list with all the currently defined column names in the same order as they are assigned to the table.

getColumnNames(): array
inherited

If the table contains columns but no names are defined, a list with empty strings will be returned

Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Response

array

A list of strings with the column names

Get all the elements that are located at the specified row index

getRow(integer $row): array
inherited
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$row

integer

An integer containing the index for the row that we want to retrieve

Response

array

All the table elements that belong to the required row

Check if the provided value contains valid CSV information.

isCSV(mixed $value): boolean
static
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$value

mixed

Object to test for valid CSV data. Accepted values are: Strings containing CSV data or CSVObject elements

Response

boolean

True if the received object represent valid CSV data. False otherwise.

Check if two provided CSV structures represent the same data

isEqualTo(mixed $csv): boolean
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$csv

mixed

A valid string or CSVObject to compare with the current one

Response

boolean

true if the two CSV elements are considered equal, false if not

Delete a whole column and all its related data from the table

removeColumn(mixed $column): void
inherited
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$column

mixed

An integer or a string containing the index or label for the column that we want to delete

Delete a whole row and all its related data from the table

removeRow(integer $row): void
inherited
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$row

integer

An integer containing the index for the row that we want to delete

Set the value for a table cell

setCell(integer $row,mixed $column,mixed $value): mixed
inherited
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$row

integer

An integer containing the index for the row that we want to set

$column

mixed

An integer or a string containing the index or label for the column that we want to set

$value

mixed

The value we want to set to the specified cell. Any type is allowed, and different cells can contain values of different types.

Response

mixed

The assigned value after beign stored into the table cell

Fill the data on all the rows for the given column index or label

setColumn(mixed $column,array $data): void
inherited
Throws
\UnexpectedValueException

Arguments

$column

mixed

An integer or a string containing the index or label for the column that we want to fill

$data

array

An array with all the values that will be assigned to the table rows on the specified column. Array length must match rows number

Set the label to an existing table column.

setColumnName(mixed $column,string $name): boolean
inherited
Throws
\UnexpectedValueException

Arguments

$column

mixed

An integer or a string containing the index or label for the column to which we want to assign a label

$name

string

The new label that will be assigned to the specified column

Response

boolean

True if the column name was correctly assigned

Define the names for the current table columns (Already defined column names will be overriden).

setColumnNames(array $names): array
inherited
Throws
\UnexpectedValueException

Arguments

$names

array

List of names that will be applied to the table columns. It must have the same number of items and in the same order as the table columns.

Response

array

The list of column names after beign assigned

Fill all the data for the specified row

setRow(integer $row,array $data): void
inherited
Throws
\UnexpectedValueException

Arguments

$row

integer

An integer containing the index for the row that we want to set

$data

array

An array with all the values that will be assigned to the table row. Array length must match columns number

Generate the textual representation for the csv data stored on this object.

toString(string $delimiter = ',',string $enclosure = '"'): string

The output of this method is ready to be stored on a physical .csv file.

Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$delimiter

string

The character that is used as the csv delimiter. ',' is set by default

$enclosure

string

The character that is used to escape fields when special characters are found

Response

string

A valid csv string ready to be stored on a .csv file