Aplus Framework Docs

Factory
in package

Class Factory.

Table of Contents

$classes  : array<string|int, mixed>
All class objects set in the current Factory.
$factories  : array<string|int, mixed>
Factory instances.
get()  : T|null
Get an object based in the FQCN.
getFactory()  : Factory
Get (existing or created) Factory instance based on a custom name.
getOrNew()  : T
Try to get an existing class instance based on FQCN.
new()  : T
Create a new object based on the FQCN.
set()  : static
Set a new object to the list of classes set.

Properties

$classes

All class objects set in the current Factory.

protected array<string|int, mixed> $classes = []

$factories

Factory instances.

protected static array<string|int, mixed> $factories = []

Methods

get()

Get an object based in the FQCN.

public get(class-string<\Framework\Factories\T> $fqcn) : T|null
Parameters
$fqcn : class-string<\Framework\Factories\T>

The Full Qualified Class Name

Tags
template

T of object

Return values
T|null

The FQCN object or null if it was not set

getFactory()

Get (existing or created) Factory instance based on a custom name.

public static getFactory([string $name = 'default' ]) : Factory
Parameters
$name : string = 'default'

The Factory name

Return values
Factory

The Factory instance

getOrNew()

Try to get an existing class instance based on FQCN.

public getOrNew(class-string<\Framework\Factories\T> $fqcn[, array<int, mixed> $construct = [] ]) : T

If it is not set, create a new instance and return it.

Parameters
$fqcn : class-string<\Framework\Factories\T>

The Full Qualified Class Name

$construct : array<int, mixed> = []

Class constructor arguments

Tags
template

T of object

Return values
T

The existing or created object

new()

Create a new object based on the FQCN.

public new(class-string<\Framework\Factories\T> $fqcn[, array<int, mixed> $construct = [] ]) : T

This method will replace the class instance.

Parameters
$fqcn : class-string<\Framework\Factories\T>

The Full Qualified Class Name

$construct : array<int, mixed> = []

Class constructor arguments

Tags
template

T of object

Return values
T

The created object

set()

Set a new object to the list of classes set.

public set(object $object) : static
Parameters
$object : object

A object

Return values
static

Search results