Compose new classes using interfaces and traits at runtime.
Traitor is a PHP library for dynamically generating classes that implement certain interfaces by use of traits. The primary purpose is for creating test mocks.
The example below creates an instance of an object that implements the
SomeInterface interface by using the
trait. It is passed the values
3 as constructor parameters.
use Icecave\Traitor\Traitor; $instance = Traitor::create() ->implements_(SomeInterface::CLASS) ->use_(SomeTrait::CLASS) ->instance(1, 2, 3);