PHPackages                             icecave/traitor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. icecave/traitor

AbandonedArchivedLibrary[Testing &amp; Quality](/categories/testing)

icecave/traitor
===============

Compose new classes using interfaces and traits at runtime.

1.0.0(11y ago)3211[1 PRs](https://github.com/IcecaveStudios/traitor/pulls)MITPHPPHP &gt;=5.4

Since Sep 3Pushed 10y ago2 watchersCompare

[ Source](https://github.com/IcecaveStudios/traitor)[ Packagist](https://packagist.org/packages/icecave/traitor)[ Docs](https://github.com/IcecaveStudios/traitor)[ RSS](/packages/icecave-traitor/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

Traitor
=======

[](#traitor)

[![Build Status](https://camo.githubusercontent.com/fbca6aa408787a8c18a9cb7d849819c99821de6f4abbef09f6a8cb1260fa11e7/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f4963656361766553747564696f732f74726169746f722f646576656c6f702e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/IcecaveStudios/traitor)[![Test Coverage](https://camo.githubusercontent.com/c218b08cbf20a6b779ebcf1d7095d876dc7d82dc447da4dd21a7f16488b629a5/687474703a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f4963656361766553747564696f732f74726169746f722f646576656c6f702e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/IcecaveStudios/traitor?branch=develop)[![SemVer](https://camo.githubusercontent.com/a789fbd8cc77cf0a9f1ea1488d398e5f5c2daddc9ed1a3f1ba07510a0d307101/687474703a2f2f696d672e736869656c64732e696f2f3a73656d7665722d312e302e302d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](http://semver.org)

**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.

- Install via [Composer](http://getcomposer.org) package [icecave/traitor](https://packagist.org/packages/icecave/traitor)
- Read the [API documentation](http://icecavestudios.github.io/traitor/artifacts/documentation/api/)

Example
-------

[](#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
----------

[](#contact-us)

- Follow [@IcecaveStudios](https://twitter.com/IcecaveStudios) on Twitter
- Visit the [Icecave Studios website](http://icecave.com.au)
- Join `#icecave` on [irc.freenode.net](http://webchat.freenode.net?channels=icecave)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Total

2

Last Release

4269d ago

Major Versions

0.1.0 → 1.0.02014-09-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/93a71bd75fcd51efee464532dbdd54927cd00e938805998c76e0a804d38fa3fb?d=identicon)[jmalloc](/maintainers/jmalloc)

---

Top Contributors

[![jmalloc](https://avatars.githubusercontent.com/u/761536?v=4)](https://github.com/jmalloc "jmalloc (17 commits)")

---

Tags

testingmockingcodemockinterfacetraitgenerate

### Embed Badge

![Health badge](/badges/icecave-traitor/health.svg)

```
[![Health](https://phpackages.com/badges/icecave-traitor/health.svg)](https://phpackages.com/packages/icecave-traitor)
```

###  Alternatives

[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k497.0M23.6k](/packages/mockery-mockery)[dg/bypass-finals

Removes final keyword from source code on-the-fly and allows mocking of final methods and classes

56426.3M456](/packages/dg-bypass-finals)[php-mock/php-mock

PHP-Mock can mock built-in PHP functions (e.g. time()). PHP-Mock relies on PHP's namespace fallback policy. No further extension is needed.

36918.1M98](/packages/php-mock-php-mock)[phake/phake

The Phake mock testing library

4758.0M324](/packages/phake-phake)[brain/monkey

Mocking utility for PHP functions and WordPress plugin API

33412.5M350](/packages/brain-monkey)[php-mock/php-mock-phpunit

Mock built-in PHP functions (e.g. time()) with PHPUnit. This package relies on PHP's namespace fallback policy. No further extension is needed.

1718.2M399](/packages/php-mock-php-mock-phpunit)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
