\League\FactoryMuffin\GeneratorsFactory

This is the factory generator class.

The factory generator can be useful for setting up relationships between models. The factory generator will return the model id of the model you ask it to generate. 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
getId()
$generators
$methods
$properties
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

$methods : array<mixed,string>

Generate, and return the attribute.

Type

array<mixed,string>

$properties

$properties : array<mixed,string>

The factory properties.

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() : integer|null

Return generated data.

Returns

integer|null

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

getId()

getId(object  $object) : integer|null

Get the model id.

Parameters

object $object

The model instance.

Returns

integer|null