Base class for domain models

abstract

 Methods

Construct a new object and extract data

__construct(array $data, bool $isDirty) 

Parameters

$data

array

$isDirty

bool

new data is dirty, defaults to true

Proxy to disclose method

__get(String $key) : mixed

Parameters

$key

String

Returns

mixed

Magic set method Do not allow set

__set(string $name, mixed $value) 

Parameters

$name

string

$value

mixed

Exceptions

\Moneybird\Domainmodel\Exception

Discloses all values of the object that should be visible in the view layer.

disclose(mixed $key) : mixed

access public

Parameters

$key

mixed

Returns

mixed

Returns an array representation of this object's dirty attributes

getDirtyAttributes() : array

access public

Returns

array

Return the objects id or null

getId() : int

Returns

int

Returns true if the object contains any dirty attributes

isDirty() : bool

access public

Returns

bool

Sets data

setData(array $data, bool $isDirty) 

Parameters

$data

array

$isDirty

bool

new data is dirty, defaults to true

Returns an array representation of this object

toArray() : array

access public

Returns

array

Create disclosedAttributes array

_initDisclosedAttributes() 

Initialize vars

_initVars() 

Copy the object

copy(array $filter) : \Moneybird\Domainmodel\self

Parameters

$filter

Array

Attributes not to copy

Returns

\Moneybird\Domainmodel\self

Extract will take an array and try to automatically map the array values to properties in this object

extract(array $values, Array $filter, bool $isDirty) 

access protected

Parameters

$values

Array

$filter

Array

$isDirty

bool

new data is dirty, defaults to true

Initialize

init() 

Adopt the data from $self

reload(\Moneybird\Domainmodel\AbstractModel $self) : \Moneybird\Domainmodel\self

Parameters

Returns

\Moneybird\Domainmodel\self

Returns an array representation of this object

selfToArray(array $filter) : array

access protected

Parameters

$filter

Returns

array

Set dirty state to clean

setClean(string $attr) : \Moneybird\Domainmodel\self

Parameters

$attr

string

Name of attribute, if null (default) set all attribures clean

Returns

\Moneybird\Domainmodel\self

Set dirty state to dirty

setDirty(string $attr) : \Moneybird\Domainmodel\self

Parameters

$attr

string

Name of attribute, if null (default) set all attribures dirty

Returns

\Moneybird\Domainmodel\self

Set dirty state based on bool

setDirtyState(bool $isDirty, string $attr) : \Moneybird\Domainmodel\self

Parameters

$isDirty

bool

$attr

string

Name of attribute, if null (default) change state of all attribures

Returns

\Moneybird\Domainmodel\self

Validate object

validate() : bool

Returns

bool

 Properties

 

Array of attributes that are dirty

$_dirtyAttr : Array

 

Array containing attributes to disclose

$_discloseAttr : array

access protected
 

Disclosure

$_disclosure : \Moneybird\Disclosure

access protected
 

Array of attributes that can't be modified

$_readonlyAttr : Array

 

Array of attributes that are required

$_requiredAttr : Array