Identity Map object.

Helps prevent duplication of objects within the system, preventing bugs with overwriting changes etc. All watched objects should return a unique string (usually it will actually be an integer, but strings are supported). via a getID() method.

package dstruct_common

 Methods

Add an object to be watched.

add(object $obj) 
Static

Parameters

$obj

object

Is an object already being watched?

exists(string $classname, string $id) : mixed
Static

This takes class name and id as the check should be made before the new object would have been instanced!

Parameters

$classname

string

$id

string

Returns

mixedThe object, if it is found, or false.

Number of times watched objects were found.

getCacheHits() : integer
Static

Returns

integer

Objects watched.

getObjectCount() : integer
Static
todo changed - needs checking

Returns

integer

Get an instance of this Singleton object.

instance() : object
Static

Returns

object

Remove an object from being watched.

remove(object $obj) : boolean
Static

Parameters

$obj

object

Returns

booleanTrue on success, false if object not found.

Class constructor.

__construct() 

Generate key to identify object.

globalKey(object $obj) : string

Watched objects are identified by their class and their ID

Parameters

$obj

object

Returns

string

 Properties

 

$cachehits : integer
 

$instance : object
 

$objs : array