\League\FactoryMuffinFacade

This is the facade class.

This is the main point of entry for using Factory Muffin. This class dynamically proxies static method calls to the underlying factory.

Summary

Methods
Properties
Constants
reset()
__callStatic()
setSaveMethod()
setDeleteMethod()
setCustomMaker()
setCustomSetter()
setCustomSaver()
setCustomDeleter()
seed()
create()
pending()
isPending()
saved()
isSaved()
isPendingOrSaved()
deleteSaved()
instance()
attributesFor()
define()
generateAttr()
getFaker()
loadFactories()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
factory()
$factory
N/A

Properties

Methods

__callStatic()

__callStatic(string  $method, array  $args) : mixed

Handle dynamic, static calls to the object.

Parameters

string $method
array $args

Returns

mixed

setSaveMethod()

setSaveMethod(string  $method) : \League\FactoryMuffin\Factory

Set the method we use when saving objects.

Parameters

string $method

Returns

\League\FactoryMuffin\Factory

setDeleteMethod()

setDeleteMethod(string  $method) : \League\FactoryMuffin\Factory

Set the method we use when deleting objects.

Parameters

string $method

Returns

\League\FactoryMuffin\Factory

setCustomMaker()

setCustomMaker(\Closure  $maker) : \League\FactoryMuffin\Factory

Set the custom maker closure.

Parameters

\Closure $maker

Returns

\League\FactoryMuffin\Factory

setCustomSetter()

setCustomSetter(\Closure  $setter) : \League\FactoryMuffin\Factory

Set the custom setter closure.

Parameters

\Closure $setter

Returns

\League\FactoryMuffin\Factory

setCustomSaver()

setCustomSaver(\Closure  $saver) : \League\FactoryMuffin\Factory

Set the custom saver closure.

Parameters

\Closure $saver

Returns

\League\FactoryMuffin\Factory

setCustomDeleter()

setCustomDeleter(\Closure  $deleter) : \League\FactoryMuffin\Factory

Set the custom deleter closure.

Parameters

\Closure $deleter

Returns

\League\FactoryMuffin\Factory

seed()

seed(integer  $times, string  $model, array  $attr = array() : array

) Returns multiple versions of an object.

Parameters

integer $times
string $model
array $attr

Returns

array

create()

create(string  $model, array  $attr = array() : object

) Creates and saves in db an instance of the model.

Parameters

string $model
array $attr

Returns

object

pending()

pending() : array

Return an array of objects to be saved.

Returns

array

isPending()

isPending(object  $object) : boolean

Is the object going to be saved?

Parameters

object $object

Returns

boolean

saved()

saved() : array

Return an array of saved objects.

Returns

array

isSaved()

isSaved(object  $object) : boolean

Is the object saved?

Parameters

object $object

Returns

boolean

isPendingOrSaved()

isPendingOrSaved(object  $object) : boolean

Is the object saved or will be saved?

Parameters

object $object

Returns

boolean

deleteSaved()

deleteSaved() : \League\FactoryMuffin\Factory

Call the delete method on any saved objects.

Returns

\League\FactoryMuffin\Factory

instance()

instance(string  $model, array  $attr = array() : object

) Return an instance of the model.

Parameters

string $model
array $attr

Returns

object

attributesFor()

attributesFor(object  $object, array  $attr = array() : array

) Returns the mock attributes for the model.

Parameters

object $object
array $attr

Returns

array

define()

define(string  $model, array  $definition = array() : \League\FactoryMuffin\Factory

) Define a new model factory.

Parameters

string $model
array $definition

Returns

\League\FactoryMuffin\Factory

generateAttr()

generateAttr(string  $kind, object|null  $object = null) : string|object

Generate the attributes.

Parameters

string $kind
object|null $object

Returns

string|object

getFaker()

getFaker() : \Faker\Generator

Get the faker instance.

Returns

\Faker\Generator

loadFactories()

loadFactories(string|array<mixed,string>  $paths) : \League\FactoryMuffin\Factory

Load the specified factories.

Parameters

string|array<mixed,string> $paths

Returns

\League\FactoryMuffin\Factory

factory()

factory() : \League\FactoryMuffin\Factory

Get the underlying factory instance.

We'll always cache the instance and reuse it.

Returns

\League\FactoryMuffin\Factory