The entity class is a representation of data from a data source as an object.

package Cactus
author Dave Widmer

 Methods

If data is passed into the entity it will be marked as new, otherwise it is an existing "row" of data.

__construct(array $data, array $structure) 

Parameters

$data

array

Initial data for a new entity.

$structure

array

The data structure of the entity properties

Magic "getter".

__get(string $name) 

Parameters

$name

string

The property name to get.

Magic "setter"

__set(string $name, mixed $value) 

Parameters

$name

string

The property name

$value

mixed

The property value

Gets the data as an array.

asArray(array $keys) : array

Parameters

$keys

array

A list of keys to pull out in case all of the data isn't needed.

Returns

array

Sets an array of properties.

fill(array $data) 

Parameters

$data

array

The data to set

Gets an array of all of the internal data that have been modified.

getModifiedData() : array

Returns

array

Is this a new Entity?

isNew() : boolean

Returns

boolean

Resets all of the modified data.

reset() : \Cactus\Entity

Returns

Reverts all native php types back to their string values.

revert(array $data) : array

Parameters

$data

array

The data to revert. Uses internal data if nothing is passed in.

Returns

array

Converts strings over to native php data types.

convert(string $name, mixed $value) : mixed

Parameters

$name

string

The name of the property

$value

mixed

The current value

Returns

mixedThe converted value

Gets the data type from the data structure.

getDataType(string $name) : mixed

Parameters

$name

string

The property name to get the type of

Returns

mixedA string data type or boolean false

 Properties

 

The class used to convert strings into native php types

$converter : \Cactus\Converter

 

The data structure for all internal data

$dataStructure : array

 

The class used to revert data back into strings.

$reverter : \Cactus\Reverter

 

The internal data storage array

$data : array

 

Is this a new object?

$is_new : boolean

 

A list of properties that have been modified.

$modified : array