A simple class providing object oriented interface over class invoking
First you need to import it by requiring composer autoloader AND then importing it in class that will use it
use SunnyFlail\ObjectCreator\ObjectCreator;
First you need a common object creator instance and then invoke ObjectCreator::create
passing fully qualified class name as an argument (the namespaced CANNOT contain leading backslashes).
This returns a mutable copy of ObjectCreator
$creator = new ObjectCreator();
$concreteCreator = $creator->create(Entity::class);
To set properties just invoke ObjectCreator::withProperty
on initialised copy, passing name of the property as first value, and value as second.
This returns the copy so you can chain it.
$concreteCreator->withProperty("propertyName", "value");
To get the object invoke ObjectCreator::getObject
on initalised copy.
$object = $concreteCreator->getObject();
You can make your custom implementation of this by implementing interface IObjectCreator
.