PHP Class Yosymfony\Spress\Core\Support\AttributesResolver

Inspired by Symfony OptionsResolver component: http://symfony.com/doc/current/components/options_resolver.html.
Author: Victor Puertas ([email protected])
Afficher le fichier Open project: spress/spress Class Usage Examples

Méthodes publiques

Méthode Description
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.

Method Details

clear() public méthode

Remove all attributes.
public clear ( )

count() public méthode

Return the number of set options.
public count ( ) : integer
Résultat integer

hasDefault() public méthode

Return whether a default value is set for an attribute.
public hasDefault ( $attribute ) : boolean
Résultat boolean

remove() public méthode

Removes the attributes with the given name.
public remove ( $attributes ) : AttributesResolver
Résultat AttributesResolver This instance

resolve() public méthode

If an attribute is marked as nullable the validate function never will be invoked.
public resolve ( array $attributes ) : array
$attributes array
Résultat array The merged and validated options

setDefault() public méthode

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?
Résultat AttributesResolver This instance

setValidator() public méthode

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) { // ... } ```
Résultat AttributesResolver This instance