PHP Класс Dice\Dice

Показать файл Открыть проект Примеры использования класса

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

Метод Описание
addRule ( string $name, array $rule ) Add a rule $rule to the class $name
create ( $name, array $args = [], array $share = [] ) : object Returns a fully constructed object based on $name using $args and $share as constructor arguments if supplied
getRule ( $name ) : array Returns the rule that will be applied to the class $name when calling create()

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

Метод Описание
expand ( mixed $param, array $share = [], boolean $createFromString = false ) : mixed Looks for 'instance' array keys in $param and when found returns an object based on the value see {@link https:// r.je/dice.html#example3-1}
getClosure ( string $name, array $rule ) : callable Returns a closure for creating object $name based on $rule, caching the reflection object for later use
getParams ( ReflectionMethod $method, array $rule ) : callable Returns a closure that generates arguments for $method based on $rule and any $args passed into the closure

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

addRule() публичный Метод

Add a rule $rule to the class $name
public addRule ( string $name, array $rule )
$name string The name of the class to add the rule for
$rule array The container can be fully configured using rules provided by associative arrays. See {@link https://r.je/dice.html#example3} for a description of the rules.

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

Returns a fully constructed object based on $name using $args and $share as constructor arguments if supplied
public create ( $name, array $args = [], array $share = [] ) : object
$args array An array with any additional arguments to be passed into the constructor upon instantiation
$share array Whether or not this class instance be shared, so that the same instance is passed around each time
Результат object A fully constructed object based on the specified input arguments

getRule() публичный Метод

Returns the rule that will be applied to the class $name when calling create()
public getRule ( $name ) : array
Результат array The rules for the specified class