PHP Class Gajus\MOA\Mother

Inheritance: implements ArrayAccess, implements Psr\Log\LoggerAwareInterface
Datei anzeigen Open project: gajus/moa

Protected Properties

Property Type Description
$data
$db
$logger

Public Methods

Method Description
__construct ( PDO $db, integer $id = null )
delete ( ) Delete object from the database. Deleted object retains its data except for the primary key value.
get ( string $name ) : mixed Get object property.
getData ( ) : array Get object data in an associative array.
getDatabaseHandle ( ) : PDO Get database handle used to instantiate the object.
getRequiredProperties ( ) : array Properties that are not nullable and do not have a default value.
getSynchronisationCount ( ) : integer Synchronisation count is used for unit testing only.
offsetExists ( mixed $offset ) : boolean
offsetGet ( mixed $offset ) : mixed
offsetSet ( mixed $offset, $value ) : void
offsetUnset ( mixed $offset ) : void
populate ( array $data ) : Gajus\MOA\Mother Shorthand method to pass each array key, value pair to the setter.
save ( ) Save the object to the database. Depending on whether object's primary key is set this method will either attempt to insert the object to the database or update an existing entry.
set ( string $name, mixed $value = null ) : boolean Set object property.
setLogger ( Psr\Log\LoggerInterface $logger ) : null Sets a logger instance on the object

Protected Methods

Method Description
afterDelete ( ) : void Triggered after DELETE query but before the transaction is committed.
afterInsert ( ) : void Triggered after INSERT query but before the transaction is committed.
afterUpdate ( ) : void Triggered after UPDATE query but before the transaction is committed.
validateSave ( ) : null | mixed Triggered when an attempt is made to save object state.
validateSet ( string $name, mixed $value ) : null | string Triggered when an attempt is made to change object property.

Private Methods

Method Description
synchronise ( ) : void Use the primary key to update object instance with the data from the database.

Method Details

__construct() public method

public __construct ( PDO $db, integer $id = null )
$db PDO
$id integer

afterDelete() protected method

Triggered after DELETE query but before the transaction is committed.
protected afterDelete ( ) : void
return void

afterInsert() protected method

Triggered after INSERT query but before the transaction is committed.
protected afterInsert ( ) : void
return void

afterUpdate() protected method

Triggered after UPDATE query but before the transaction is committed.
protected afterUpdate ( ) : void
return void

delete() public method

Delete object from the database. Deleted object retains its data except for the primary key value.
public delete ( )

get() public method

Get object property.
public get ( string $name ) : mixed
$name string Property name.
return mixed

getData() public method

Get object data in an associative array.
public getData ( ) : array
return array

getDatabaseHandle() public method

Get database handle used to instantiate the object.
public getDatabaseHandle ( ) : PDO
return PDO

getRequiredProperties() public method

Properties that are not nullable and do not have a default value.
public getRequiredProperties ( ) : array
return array

getSynchronisationCount() public method

This method must not be used in the application code.

offsetExists() public method

public offsetExists ( mixed $offset ) : boolean
$offset mixed
return boolean

offsetGet() public method

public offsetGet ( mixed $offset ) : mixed
$offset mixed
return mixed

offsetSet() public method

public offsetSet ( mixed $offset, $value ) : void
$offset mixed
return void

offsetUnset() public method

public offsetUnset ( mixed $offset ) : void
$offset mixed
return void

populate() public method

Shorthand method to pass each array key, value pair to the setter.
public populate ( array $data ) : Gajus\MOA\Mother
$data array
return Gajus\MOA\Mother

save() public method

Save the object to the database. Depending on whether object's primary key is set this method will either attempt to insert the object to the database or update an existing entry.
public save ( )

set() public method

Set object property.
public set ( string $name, mixed $value = null ) : boolean
$name string Property name.
$value mixed
return boolean Returns true if object state has been affected.

setLogger() public method

Sets a logger instance on the object
public setLogger ( Psr\Log\LoggerInterface $logger ) : null
$logger Psr\Log\LoggerInterface
return null

validateSave() protected method

Returning an error message will discard the transaction and throw Gajus\MOA\Exception\ValidationException exception.
protected validateSave ( ) : null | mixed
return null | mixed

validateSet() protected method

Returning an error message will discard the transaction and throw Gajus\MOA\Exception\ValidationException exception.
protected validateSet ( string $name, mixed $value ) : null | string
$name string
$value mixed
return null | string

Property Details

$data protected_oe property

protected $data

$db protected_oe property

protected $db

$logger protected_oe property

protected $logger