Also, I added a Prototyped Lifecycle class. It should work exactly like the "Reused" class except it returns a deep object clone instead of the same instance over and over.
class Prototyped extends Lifecycle {
private $instance;
function instantiate($dependencies) {
if (! isset($this->instance)) {
$this->instance = call_user_func_array(
array(new ReflectionClass($this->class), 'newInstance'),
$dependencies);
}
return clone($this->instance);
}
}
Also, I added a Prototyped Lifecycle class. It should work exactly like the "Reused" class except it returns a deep object clone instead of the same instance over and over.
class Prototyped extends Lifecycle {
private $instance;
function instantiate($dependencies) {
if (! isset($this->instance)) {
$this->instance = call_user_func_array(
array(new ReflectionClass($this->class), 'newInstance'),
$dependencies);
}
return clone($this->instance);
}
}
http://en.wikipedia.org/wiki/Prototype_pattern