PHPackages                             mooti/factory - 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. mooti/factory

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

mooti/factory
=============

Small library for helping create testable code

1.0.0(10y ago)012.5k3Apache-2.0PHPPHP &gt;=5.5.9

Since Apr 20Pushed 9y ago1 watchersCompare

[ Source](https://github.com/mooti/factory)[ Packagist](https://packagist.org/packages/mooti/factory)[ RSS](/packages/mooti-factory/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (2)Versions (8)Used By (3)

Mooti Factory
=============

[](#mooti-factory)

[![Build Status](https://camo.githubusercontent.com/dbae1b823827da907b5f74a9635f29276a6276135991607e5c47bac315ef48c0/68747470733a2f2f7472617669732d63692e6f72672f6d6f6f74692f666163746f72792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mooti/factory)[![Coverage Status](https://camo.githubusercontent.com/ffc405bdab4a2ea9451f334690f48cbf451e600433bc2bae0b3838314c5ddc07/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d6f6f74692f666163746f72792f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/mooti/factory?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/3c0e7e16cceafa0973766950cf20ee035c898aa05c02d5075c278cb4e22cb9d7/68747470733a2f2f706f7365722e707567782e6f72672f6d6f6f74692f666163746f72792f762f737461626c65)](https://packagist.org/packages/mooti/factory)[![Total Downloads](https://camo.githubusercontent.com/2f91f67c170e323fa877ed795fc99487f3f1f7018f119653ced77b86fe75aa91/68747470733a2f2f706f7365722e707567782e6f72672f6d6f6f74692f666163746f72792f646f776e6c6f616473)](https://packagist.org/packages/mooti/factory)[![Latest Unstable Version](https://camo.githubusercontent.com/d334ef0e482ed1280ab32911fcd684ba7f1cdc7de8c38582b31a70957f9fd88f/68747470733a2f2f706f7365722e707567782e6f72672f6d6f6f74692f666163746f72792f762f756e737461626c65)](https://packagist.org/packages/mooti/factory)[![License](https://camo.githubusercontent.com/8d2862c8e4b3f9f7ca7aead17327cb2ad47e929841c262330c204f836b510546/68747470733a2f2f706f7365722e707567782e6f72672f6d6f6f74692f666163746f72792f6c6963656e7365)](https://packagist.org/packages/mooti/factory)

A small repo to aid in creating simple clean factory code without the need to use a dependancy injection container or create numerous factory classes. It replaces the `new` keyword with a method call enabling you to easily mock objects.

### Installation

[](#installation)

You can install this through packagist:

```
$ composer require mooti/factory

```

### Run the tests

[](#run-the-tests)

If you would like to run the tests. Use the following:

```
$ ./vendor/bin/phpunit -c config/phpunit.xml

```

### Usage

[](#usage)

Say you have a class Foo that will be used within another class Bar. Given you have the following Foo.php.

```
