\Piko\ModelTrait

Base model trait.

Properties summary

Name Description
protected $errors Errors hash container

Methods summary

Name Description
public bind Bind the data to the model attribubes.
public getErrors Return the errors hash container
public isValid Check if the model is valid
public toArray Get the model data as an associative array.
protected getAttributes Get the public properties reprenting the data mode…
protected setError Set an error that will be appended to the errors c…
protected validate Validate this model (Should be extended). Inherite…

Properties

protected $errors : string[]

Errors hash container


Methods

public bind(): void

public  bind(array  $data): void

Bind the data to the model attribubes.

Parameters

$data : An array of data (name-value pairs).


public getErrors(): string[]

public  getErrors(): string[]

Return the errors hash container

Return:

string[]


public isValid(): bool

public  isValid(): bool

Check if the model is valid

Return:

bool


public toArray(): array

public  toArray(): array

Get the model data as an associative array.

Return:

array


protected getAttributes(): array

protected  getAttributes(): array

Get the public properties reprenting the data model

Return:

array


protected setError(): void

protected  setError(string  $errorName, string  $errorMsg): void

Set an error that will be appended to the errors container

Parameters

$errorName :

$errorMsg :

see \Piko\ModelTrait::$errors


protected validate(): void

protected  validate(): void

Validate this model (Should be extended). Inherited method should fill the errors array using the setError method if the model is not valid.

see \Piko\ModelTrait::setError()

see \Piko\ModelTrait::isValid()

codeCoverageIgnore