Closed Matthimatiker closed 12 years ago
Created helper class Mol_Util_ObjectBuilder
. The builder accepts an optional type constraint as constructor argument. The method create()
is used to instantiate classes that meet the type requirements.
Example:
$builder = new Mol_Util_ObjectBuilder('Countable');
$initialValues = array(1, 2, 3);
$object = $builder->create('ArrayObject', array($initialValues));
Create a factory that is able to create instances of a specified type.
It should be possible to provide a type constraint. When a class instance is requested then the factory should check if it meets the type requirement (before creating the object).
That factory could be useful if it is possible to configure classes, but type constraints must be enforced (for example implementation of an interface).