PHP Класс Yosymfony\Spress\Core\Support\AttributesResolver

Inspired by Symfony OptionsResolver component: http://symfony.com/doc/current/components/options_resolver.html.
Автор: Victor Puertas ([email protected])
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
clear ( ) Remove all attributes.
count ( ) : integer Return the number of set options.
hasDefault ( $attribute ) : boolean Return whether a default value is set for an attribute.
remove ( $attributes ) : AttributesResolver Removes the attributes with the given name.
resolve ( array $attributes ) : array Merges options with the default values and validates them.
setDefault ( string $attribute, mixed $value, string $type = null, boolean $required = false, boolean $nullable = false ) : AttributesResolver Sets the default value of a given attribute.
setValidator ( string $attribute, Closure $validator ) : AttributesResolver Sets the validator for an atribute.

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

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

Remove all attributes.
public clear ( )

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

Return the number of set options.
public count ( ) : integer
Результат integer

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

Return whether a default value is set for an attribute.
public hasDefault ( $attribute ) : boolean
Результат boolean

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

Removes the attributes with the given name.
public remove ( $attributes ) : AttributesResolver
Результат AttributesResolver This instance

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

If an attribute is marked as nullable the validate function never will be invoked.
public resolve ( array $attributes ) : array
$attributes array
Результат array The merged and validated options

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

Sets the default value of a given attribute.
public setDefault ( string $attribute, mixed $value, string $type = null, boolean $required = false, boolean $nullable = false ) : AttributesResolver
$attribute string The name of the attribute
$value mixed The default value of the attribute
$type string The accepted type. Any type for which a corresponding is_() function exists is acceptable
$required boolean Is that attribute required?
$nullable boolean Is that attribute nullable?
Результат AttributesResolver This instance

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

Sets the validator for an atribute.
public setValidator ( string $attribute, Closure $validator ) : AttributesResolver
$attribute string The name of the attribute
$validator Closure The validator should be a closure with the following signature: ```php function ($value) { // ... } ```
Результат AttributesResolver This instance