Compose new classes using interfaces and traits at runtime.
PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.gitattributes
.gitignore
.travis.env
.travis.install
.travis.key
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
LICENSE.md
README.md
composer.json
composer.lock

README.md

Traitor

Build Status Test Coverage SemVer

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.

Example

The example below creates an instance of an object that implements the SomeInterface interface by using the SomeTrait trait. It is passed the values 1, 2, and 3 as constructor parameters.

use Icecave\Traitor\Traitor;

$instance = Traitor::create()
    ->implements_(SomeInterface::CLASS)
    ->use_(SomeTrait::CLASS)
    ->instance(1, 2, 3);

Contact us