\League\FactoryMuffin\GeneratorsClosure

This is the closure generator class.

The closure generator can be used if you want a more custom solution. Whatever you return from the closure you write will be set as the attribute. Please note that class is not be considered part of the public api, and should only be used internally by Factory Muffin.

Summary

Methods
Properties
Constants
__construct()
detect()
getOptions()
generate()
No public properties found
No constants found
getGenerator()
getGeneratorWithoutPrefix()
getPrefix()
factory()
$kind
$object
$faker
N/A
No private methods found
$generators
N/A

Properties

$kind

$kind : string

The kind of attribute that will be generated.

Type

string

$object

$object : object|null

The model instance.

Type

object|null

$faker

$faker : \Faker\Generator|null

The faker factory or generator instance.

Type

\Faker\Generator|null

$generators

$generators : array<mixed,string>

The generator classes that are available.

Type

array<mixed,string>

Methods

__construct()

__construct(string  $kind, object|null  $object = null, \Faker\Generator|null  $faker = null) : void

Initialise our Generator.

Parameters

string $kind

The kind of attribute

object|null $object

The model instance.

\Faker\Generator|null $faker

The faker instance.

detect()

detect(string  $kind, object|null  $object = null, \Faker\Generator|null  $faker = null) : \League\FactoryMuffin\Generators\Base

Detect the type of Generator we are processing.

Parameters

string $kind

The kind of attribute.

object|null $object

The model instance.

\Faker\Generator|null $faker

The faker instance.

Returns

\League\FactoryMuffin\Generators\Base

getOptions()

getOptions() : array

Return an array of all options passed to the Generator (after |).

Returns

array

generate()

generate() : mixed

Generate, and return the attribute.

Returns

mixed

getGenerator()

getGenerator() : string

Returns the name of the kind supplied (exploding at |).

Returns

string

getGeneratorWithoutPrefix()

getGeneratorWithoutPrefix() : string

Returns the name of the kind without a prefix.

Returns

string

getPrefix()

getPrefix() : string

Returns the prefix to the Generator. This can be "unique", or "optional".

Returns

string

factory()

factory(string  $model) : object

Create an instance of the model.

This model will be automatically saved to the database if the model we are generating it for has been saved (the create function was used).

Parameters

string $model

Model class name.

Returns

object