\League\FactoryMuffin\GeneratorsGeneric

This is the generic generator class.

The generic generator will be the generator you use the most. It will communicate with the faker library in order to generate your 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
execute()
$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.

We attempt to use Faker for any string passed in. If a Faker property does not exist, we'll return the original string.

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

execute()

execute() : mixed

Call faker to generate the attribute.

Returns

mixed