PHP Класс League\FactoryMuffin\FactoryMuffin

Автор: Graham Campbell ([email protected])
Автор: Scott Robertson ([email protected])
Автор: Patrick McCarren ([email protected])
Автор: Zizaco ([email protected])
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$factory League\FactoryMuffin\Generators\GeneratorFactory The generator factory instance.
$store League\FactoryMuffin\Stores\StoreInterface The store instance.

Открытые методы

Метод Описание
__construct ( League\FactoryMuffin\Stores\StoreInterface $store = null, GeneratorFactory $factory = null ) : void Create a new factory muffin instance.
camelize ( string $str ) : string Camelize string.
create ( string $name, array $attr = [] ) : object Creates and saves a model.
define ( string $name ) : League\FactoryMuffin\Definition Define a new model definition.
deleteSaved ( ) : FactoryMuffin Delete all the saved models.
getDefinition ( string $name ) : League\FactoryMuffin\Definition Get a model definition.
getDefinitions ( ) : League\FactoryMuffin\Definition[] Get all defined model definitions.
instance ( string $name, array $attr = [] ) : object Return an instance of the model.
isPendingOrSaved ( object $model ) : boolean Is the object saved or will be saved?
loadFactories ( string | string[] $paths ) : FactoryMuffin Load the specified factories.
seed ( integer $times, string $name, array $attr = [] ) : object[] Creates and saves multiple versions of a model.

Защищенные методы

Метод Описание
generate ( object $model, array $attr = [] ) : void Generate and set the model attributes.
make ( string $name, array $attr, boolean $save ) : object Make an instance of a model.
makeClass ( string $class, callable $maker = null ) : object Make an instance of a class.
triggerCallback ( object $model, string $name ) : boolean Trigger the callback if we have one.

Приватные методы

Метод Описание
loadDirectory ( string $path ) : void Load all the files in a directory.

Описание методов

__construct() публичный метод

Create a new factory muffin instance.
public __construct ( League\FactoryMuffin\Stores\StoreInterface $store = null, GeneratorFactory $factory = null ) : void
$store League\FactoryMuffin\Stores\StoreInterface The store instance.
$factory League\FactoryMuffin\Generators\GeneratorFactory The generator factory instance.
Результат void

camelize() публичный статический метод

Transforms a string to camel case (e.g. first_name -> firstName).
public static camelize ( string $str ) : string
$str string String in underscore format.
Результат string

create() публичный метод

Creates and saves a model.
public create ( string $name, array $attr = [] ) : object
$name string The model definition name.
$attr array The model attributes.
Результат object

define() публичный метод

Note that this method cannot be used to modify existing definitions. Please use the getDefinition method for that.
public define ( string $name ) : League\FactoryMuffin\Definition
$name string The model definition name.
Результат League\FactoryMuffin\Definition

deleteSaved() публичный метод

Delete all the saved models.
public deleteSaved ( ) : FactoryMuffin
Результат FactoryMuffin

generate() защищенный метод

Generate and set the model attributes.
protected generate ( object $model, array $attr = [] ) : void
$model object The model instance.
$attr array The model attributes.
Результат void

getDefinition() публичный метод

Get a model definition.
public getDefinition ( string $name ) : League\FactoryMuffin\Definition
$name string The model definition name.
Результат League\FactoryMuffin\Definition

getDefinitions() публичный метод

Get all defined model definitions.
public getDefinitions ( ) : League\FactoryMuffin\Definition[]
Результат League\FactoryMuffin\Definition[]

instance() публичный метод

This does not save it in the database. Use create for that.
public instance ( string $name, array $attr = [] ) : object
$name string The model definition name.
$attr array The model attributes.
Результат object

isPendingOrSaved() публичный метод

Is the object saved or will be saved?
public isPendingOrSaved ( object $model ) : boolean
$model object The model instance.
Результат boolean

loadFactories() публичный метод

This method expects either a single path to a directory containing php files, or an array of directory paths, and will "require" each file. These files should be where you define your model definitions.
public loadFactories ( string | string[] $paths ) : FactoryMuffin
$paths string | string[] The directory path(s) to load.
Результат FactoryMuffin

make() защищенный метод

Make an instance of a model.
protected make ( string $name, array $attr, boolean $save ) : object
$name string The model definition name.
$attr array The model attributes.
$save boolean Are we saving, or just creating an instance?
Результат object

makeClass() защищенный метод

Make an instance of a class.
protected makeClass ( string $class, callable $maker = null ) : object
$class string The model class name.
$maker callable The maker callable.
Результат object

seed() публичный метод

Under the hood, we're calling the create method over and over.
public seed ( integer $times, string $name, array $attr = [] ) : object[]
$times integer The number of models to create.
$name string The model definition name.
$attr array The model attributes.
Результат object[]

triggerCallback() защищенный метод

Trigger the callback if we have one.
protected triggerCallback ( object $model, string $name ) : boolean
$model object The model instance.
$name string The model definition name.
Результат boolean

Описание свойств

$factory защищенное свойство

The generator factory instance.
protected GeneratorFactory,League\FactoryMuffin\Generators $factory
Результат League\FactoryMuffin\Generators\GeneratorFactory

$store защищенное свойство

The store instance.
protected StoreInterface,League\FactoryMuffin\Stores $store
Результат League\FactoryMuffin\Stores\StoreInterface