PHP Class LightnCandy\Validator

Afficher le fichier Open project: zordius/lightncandy Class Usage Examples

Méthodes publiques

Méthode Description
helper ( array\arraystring | integer> &$context, string $name, boolean $checkSubexp = false ) : boolean Return true when the name is listed in helper table
log ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean | null Return true when this is {{log .
lookup ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean | null Return true when this is {{lookup .
resolveHelper ( array\arraystring | integer> &$context, string &$name ) : string | null use helperresolver to resolve helper, return true when helper founded
verify ( array\arraystring | integer> &$context, string $template ) Verify template

Méthodes protégées

Méthode Description
blockBegin ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean validate block begin token
blockCustomHelper ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars, boolean $inverted = false ) : integer | null validate block custom helper token
blockEnd ( array\arraystring | integer> &$context, arrayinteger | string | array> &$vars, string | null $match = null ) : boolean Return compiled PHP code for a handlebars block end token
builtin ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) validate builtin helpers
comment ( string[] &$token, array\arraystring | integer> &$context ) : boolean | null handle comment
delimiter ( string[] $token, array\arraystring | integer> &$context ) : boolean | null Verify delimiters and operators
doElse ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : integer Return 1 or larger number when else token detected
doElseChain ( array\arraystring | integer> &$context ) handle else chain
doIf ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean validate if token
inline ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean validate inline partial
inlinePartial ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean | null validate inline partial begin token
invertedSection ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : integer validate inverted section
isBlockHelper ( array\arraystring | integer> $context, arrayinteger | string | array> $vars ) : boolean | null detect for block custom helper
isDelimiter ( array\arraystring | integer> &$context ) : boolean | null handle delimiter change
operator ( string $operator, array\arraystring | integer> &$context, arrayinteger | string | array> &$vars ) : boolean | integer | null Verify operators
partial ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : integer | boolean validate partial
partialBlock ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean | null validate partial block token
pushLeft ( array\arraystring | integer> &$context ) push left string of current token and clear it
pushStack ( array\arraystring | integer> &$context, string $operation, arrayinteger | string | array> $vars ) push current token into the section stack
pushToken ( array\arraystring | integer> &$context, string | array $token ) push a token into the stack when it is not empty string
rawblock ( string[] &$token, array\arraystring | integer> &$context ) : boolean | null handle raw block
section ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars, boolean $isEach = false ) : boolean validate section token
spacing ( array &$token, array\arraystring | integer> &$context, boolean $nost = false ) : string | null Modify $token when spacing rules matched.
token ( string[] &$token, array\arraystring | integer> &$context ) Collect handlebars usage information, detect template error.
unless ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean validate unless token
with ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean validate with token

Method Details

blockBegin() protected static méthode

validate block begin token
protected static blockBegin ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat boolean Return true always

blockCustomHelper() protected static méthode

validate block custom helper token
protected static blockCustomHelper ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars, boolean $inverted = false ) : integer | null
$context array\arraystring | integer>
$vars arrayinteger | string | array>
$inverted boolean the logic will be inverted
Résultat integer | null Return number of used custom helpers

blockEnd() protected static méthode

Return compiled PHP code for a handlebars block end token
protected static blockEnd ( array\arraystring | integer> &$context, arrayinteger | string | array> &$vars, string | null $match = null ) : boolean
$context array\arraystring | integer>
$vars arrayinteger | string | array>
$match string | null should also match to this operator
Résultat boolean Return true

builtin() protected static méthode

validate builtin helpers
protected static builtin ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars )
$context array\arraystring | integer>
$vars arrayinteger | string | array>

comment() protected static méthode

handle comment
protected static comment ( string[] &$token, array\arraystring | integer> &$context ) : boolean | null
$token string[] detected handlebars {{ }} token
$context array\arraystring | integer>
Résultat boolean | null Return true when is comment

delimiter() protected static méthode

Verify delimiters and operators
protected static delimiter ( string[] $token, array\arraystring | integer> &$context ) : boolean | null
$token string[] detected handlebars {{ }} token
$context array\arraystring | integer>
Résultat boolean | null Return true when invalid

doElse() protected static méthode

Return 1 or larger number when else token detected
protected static doElse ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : integer
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat integer Return 1 or larger number when else token detected

doElseChain() protected static méthode

handle else chain
protected static doElseChain ( array\arraystring | integer> &$context )
$context array\arraystring | integer>

doIf() protected static méthode

validate if token
protected static doIf ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat boolean Return true always

helper() public static méthode

Return true when the name is listed in helper table
public static helper ( array\arraystring | integer> &$context, string $name, boolean $checkSubexp = false ) : boolean
$context array\arraystring | integer>
$name string token name
$checkSubexp boolean true when check for subexpression
Résultat boolean Return true when it is custom helper

inline() protected static méthode

validate inline partial
protected static inline ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat boolean Return true always

inlinePartial() protected static méthode

validate inline partial begin token
protected static inlinePartial ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean | null
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat boolean | null Return true when inline partial ends

invertedSection() protected static méthode

validate inverted section
protected static invertedSection ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : integer
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat integer Return number of inverted sections

isBlockHelper() protected static méthode

detect for block custom helper
protected static isBlockHelper ( array\arraystring | integer> $context, arrayinteger | string | array> $vars ) : boolean | null
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat boolean | null Return true when this token is block custom helper

isDelimiter() protected static méthode

handle delimiter change
protected static isDelimiter ( array\arraystring | integer> &$context ) : boolean | null
$context array\arraystring | integer>
Résultat boolean | null Return true when delimiter changed

log() public static méthode

..}}
public static log ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean | null
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat boolean | null Return true when it is custom helper

lookup() public static méthode

..}}
public static lookup ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean | null
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat boolean | null Return true when it is custom helper

operator() protected static méthode

Verify operators
protected static operator ( string $operator, array\arraystring | integer> &$context, arrayinteger | string | array> &$vars ) : boolean | integer | null
$operator string the operator string
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat boolean | integer | null Return true when invalid or detected

partial() protected static méthode

validate partial
protected static partial ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : integer | boolean
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat integer | boolean Return 1 or larger number for runtime partial, return true for other case

partialBlock() protected static méthode

validate partial block token
protected static partialBlock ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean | null
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat boolean | null Return true when partial block ends

pushLeft() protected static méthode

push left string of current token and clear it
protected static pushLeft ( array\arraystring | integer> &$context )
$context array\arraystring | integer>

pushStack() protected static méthode

push current token into the section stack
protected static pushStack ( array\arraystring | integer> &$context, string $operation, arrayinteger | string | array> $vars )
$context array\arraystring | integer>
$operation string operation string
$vars arrayinteger | string | array>

pushToken() protected static méthode

push a token into the stack when it is not empty string
protected static pushToken ( array\arraystring | integer> &$context, string | array $token )
$context array\arraystring | integer>
$token string | array a parsed token or a string

rawblock() protected static méthode

handle raw block
protected static rawblock ( string[] &$token, array\arraystring | integer> &$context ) : boolean | null
$token string[] detected handlebars {{ }} token
$context array\arraystring | integer>
Résultat boolean | null Return true when in rawblock mode

resolveHelper() public static méthode

use helperresolver to resolve helper, return true when helper founded
public static resolveHelper ( array\arraystring | integer> &$context, string &$name ) : string | null
$context array\arraystring | integer>
$name string helper name
Résultat string | null $content helper function name or callable

section() protected static méthode

validate section token
protected static section ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars, boolean $isEach = false ) : boolean
$context array\arraystring | integer>
$vars arrayinteger | string | array>
$isEach boolean the section is #each
Résultat boolean Return true always

spacing() protected static méthode

Modify $token when spacing rules matched.
protected static spacing ( array &$token, array\arraystring | integer> &$context, boolean $nost = false ) : string | null
$token array
$context array\arraystring | integer>
$nost boolean do not do stand alone logic
Résultat string | null Return compiled code segment for the token

token() protected static méthode

Collect handlebars usage information, detect template error.
protected static token ( string[] &$token, array\arraystring | integer> &$context )
$token string[] detected handlebars {{ }} token
$context array\arraystring | integer>

unless() protected static méthode

validate unless token
protected static unless ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat boolean Return true always

verify() public static méthode

Verify template
public static verify ( array\arraystring | integer> &$context, string $template )
$context array\arraystring | integer>
$template string handlebars template

with() protected static méthode

validate with token
protected static with ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : boolean
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat boolean Return true always