class Entity extends Data (View source)

Entity is a Data object sub class, we can set fields of this object then help us filter non necessary values to prevent error when inserting to database.

Constants

DUMP_ALL_DATA

Methods

__construct(array $fields = null, mixed $data = null)

Constructor.

bind(mixed $values, boolean $replaceNulls = false)

Bind the data into this object.

from Data
set(string $key, mixed $value = null)

Magic setter to set a table field.

mixed
get(string $key, mixed $default = null)

Magic getter to get a table field.

boolean
exists(string $field)

Method to check a field exists.

void
__set(string $field, mixed $value = null)

Set value.

boolean
__isset(string $name)

__isset

mixed
__get(string $field)

Get value.

void
__unset(string $name)

__unset

getIterator(bool $all = false)

Get an iterator object.

boolean
offsetExists(mixed $offset)

Is a property exists or not.

mixed
offsetGet(mixed $offset)

Get a property.

void
offsetSet(mixed $offset, mixed $value)

Set a value to property.

void
offsetUnset(mixed $offset)

Unset a property.

int
count()

Count this object.

boolean
isNull()

Is this object empty?

boolean
notNull()

Is this object has properties?

from Data
array
dump(bool $all = false)

Dump all data as array

map(callable $callback)

Mapping all elements.

from Data
walk(callable $callback, mixed $userdata = null)

Apply a user supplied function to every member of this object.

from Data
void
__clone()

Clone this object.

from Data
getFields()

loadFields

addField(string $field, string $default = null)

addField

addFields(array $fields)

Add a field to this entity.

removeField(string $field)

Remove field from this entity.

boolean
hasField(string $name)

Method to check a field exists or not.

setAlias(string $name, string $alias)

Set column alias.

string
resolveAlias(string $name)

Resolve alias.

reset()

Method to reset class properties to the defaults set in the class definition. It will ignore the primary key as well as any private class properties.

Details

at line line 48
__construct(array $fields = null, mixed $data = null)

Constructor.

Parameters

array $fields
mixed $data

in Data at line line 41
Data bind(mixed $values, boolean $replaceNulls = false)

Bind the data into this object.

Parameters

mixed $values The data array or object.
boolean $replaceNulls Replace null or not.

Return Value

Data Return self to support chaining.

Exceptions

InvalidArgumentException

at line line 291
Data set(string $key, mixed $value = null)

Magic setter to set a table field.

Parameters

string $key The key name.
mixed $value The value to set.

Return Value

Data Return self to support chaining.

Exceptions

InvalidArgumentException

at line line 310
mixed get(string $key, mixed $default = null)

Magic getter to get a table field.

Parameters

string $key The key name.
mixed $default The default value if not exists.

Return Value

mixed The value we want ot get.

at line line 391
boolean exists(string $field)

Method to check a field exists.

Parameters

string $field The field name to check.

Return Value

boolean True if exists.

at line line 250
void __set(string $field, mixed $value = null)

Set value.

Parameters

string $field The field to set.
mixed $value The value to set.

Return Value

void

Exceptions

InvalidArgumentException

at line line 236
boolean __isset(string $name)

__isset

Parameters

string $name

Return Value

boolean

at line line 262
mixed __get(string $field)

Get value.

Parameters

string $field The field to get.

Return Value

mixed

at line line 275
void __unset(string $name)

__unset

Parameters

string $name

Return Value

void

Exceptions

InvalidArgumentException

at line line 185
Traversable getIterator(bool $all = false)

Get an iterator object.

Parameters

bool $all

Return Value

Traversable An instance of an object implementing Iterator or Traversable

at line line 329
boolean offsetExists(mixed $offset)

Is a property exists or not.

Parameters

mixed $offset Offset key.

Return Value

boolean

at line line 342
mixed offsetGet(mixed $offset)

Get a property.

Parameters

mixed $offset Offset key.

Return Value

mixed The value to return.

Exceptions

InvalidArgumentException

at line line 356
void offsetSet(mixed $offset, mixed $value)

Set a value to property.

Parameters

mixed $offset Offset key.
mixed $value The value to set.

Return Value

void

Exceptions

InvalidArgumentException

at line line 369
void offsetUnset(mixed $offset)

Unset a property.

Parameters

mixed $offset Offset key to unset.

Return Value

void

Exceptions

InvalidArgumentException

at line line 379
int count()

Count this object.

Return Value

int

at line line 401
boolean isNull()

Is this object empty?

Return Value

boolean

in Data at line line 281
boolean notNull()

Is this object has properties?

Return Value

boolean

at line line 421
array dump(bool $all = false)

Dump all data as array

Parameters

bool $all

Return Value

array

in Data at line line 305
Data map(callable $callback)

Mapping all elements.

Parameters

callable $callback Callback to handle every element.

Return Value

Data Support chaining.

in Data at line line 325
Data walk(callable $callback, mixed $userdata = null)

Apply a user supplied function to every member of this object.

Parameters

callable $callback Callback to handle every element.
mixed $userdata This will be passed as the third parameter to the callback.

Return Value

Data Support chaining.

in Data at line line 344
void __clone()

Clone this object.

Return Value

void

at line line 77
stdClass[] getFields()

loadFields

Return Value

stdClass[]

at line line 90
Entity addField(string $field, string $default = null)

addField

Parameters

string $field
string $default

Return Value

Entity

at line line 137
Entity addFields(array $fields)

Add a field to this entity.

Parameters

array $fields Fields array.

Return Value

Entity Return self to support chaining.

at line line 154
Entity removeField(string $field)

Remove field from this entity.

Parameters

string $field Field name.

Return Value

Entity Return self to support chaining.

at line line 170
boolean hasField(string $name)

Method to check a field exists or not.

Parameters

string $name

Return Value

boolean

at line line 198
Entity setAlias(string $name, string $alias)

Set column alias.

Parameters

string $name
string $alias

Return Value

Entity

at line line 219
string resolveAlias(string $name)

Resolve alias.

Parameters

string $name

Return Value

string

at line line 447
Entity reset()

Method to reset class properties to the defaults set in the class definition. It will ignore the primary key as well as any private class properties.

Return Value

Entity