Documentation

StaticFactoryTrait

User Extended by Shawn Clake Class StaticFactoryTrait User Extended is licensed under the MIT license.

Tags
author

Shawn Clake shawn.clake@gmail.com

link
https://github.com/ShawnClake/UserExtended
license

https://github.com/ShawnClake/UserExtended/blob/master/LICENSE MIT

Used as a method of simplifying syntax whilst safely creating objects. An example would be for a Class called ClassD to have a function destroyFactory() and appendAndPrint() ClassD::destroy('never say never ')->appendAndPrint('not like this');

Any functions inside of ClassD which you desire to be factory compatible must have a function name that ends in 'Factory' However when utilizing the factory, don't write the word 'Factory' as you saw in the example above.

Table of Contents

__callStatic()  : mixed
Main factory function which utilizes PHP's magic method to call a suffixed factory function on the child class.
factory()  : mixed
Helper function which can also be used to simply create an instance of a child class in cases where initialization functions aren't needed.

Methods

__callStatic()

Main factory function which utilizes PHP's magic method to call a suffixed factory function on the child class.

public static __callStatic( $name,  $arguments) : mixed
Parameters
$name :
$arguments :
Return values
mixed

factory()

Helper function which can also be used to simply create an instance of a child class in cases where initialization functions aren't needed.

public static factory() : mixed

Generally you will want to use the static magic method below.

Return values
mixed

Search results