PHP 클래스 Yosymfony\Spress\Core\Support\AttributesResolver

Inspired by Symfony OptionsResolver component: http://symfony.com/doc/current/components/options_resolver.html.
저자: Victor Puertas ([email protected])
파일 보기 프로젝트 열기: spress/spress 1 사용 예제들

공개 메소드들

메소드 설명
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