PHP Class LightnCandy\Validator

Mostra file Open project: zordius/lightncandy Class Usage Examples

Public Methods

Method 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

Protected Methods

Method 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 method

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

blockCustomHelper() protected static method

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
return integer | null Return number of used custom helpers

blockEnd() protected static method

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
return boolean Return true

builtin() protected static method

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 method

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

delimiter() protected static method

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

doElse() protected static method

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>
return integer Return 1 or larger number when else token detected

doElseChain() protected static method

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

doIf() protected static method

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

helper() public static method

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
return boolean Return true when it is custom helper

inline() protected static method

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

inlinePartial() protected static method

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>
return boolean | null Return true when inline partial ends

invertedSection() protected static method

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

isBlockHelper() protected static method

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>
return boolean | null Return true when this token is block custom helper

isDelimiter() protected static method

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

log() public static method

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

lookup() public static method

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

operator() protected static method

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>
return boolean | integer | null Return true when invalid or detected

partial() protected static method

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

partialBlock() protected static method

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>
return boolean | null Return true when partial block ends

pushLeft() protected static method

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

pushStack() protected static method

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 method

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 method

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

resolveHelper() public static method

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
return string | null $content helper function name or callable

section() protected static method

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
return boolean Return true always

spacing() protected static method

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
return string | null Return compiled code segment for the token

token() protected static method

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 method

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

verify() public static method

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

with() protected static method

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