Class LightnCandy\Expression

# Class Expression

LightnCandy Expression handler

Namespace: LightnCandy
Located at Expression.php

Methods summary
`public static string` | # `boolString( integer $v )` return 'true' or 'false' string. return 'true' or 'false' string. #### Parameters $v value #### Returns string 'true' when the value larger then 0 #### Expect 'true' when input 1 'true' when input 999 'false' when input 0 'false' when input -1
`public static string` | # `listString( array<string> $list )` Get string presentation for a string list Get string presentation for a string list #### Parameters $list an array of strings. #### Returns string PHP list string #### Expect '' when input array() "'a'" when input array('a') "'a','b','c'" when input array('a', 'b', 'c')
`public static string` | # `arrayString( array<string> $list )` Get string presentation for an array Get string presentation for an array #### Parameters $list an array of variable names. #### Returns string PHP array names string #### Expect '' when input array() "['a']" when input array('a') "['a']['b']['c']" when input array('a', 'b', 'c')
`public static array<integer|boolean|array>` | # `analyze( array<string,array|string|integer> $context, array<array|string|integer> $var )` Analyze an expression Analyze an expression #### Parameters $context Current context $var variable parsed path #### Returns array<integer|boolean|array> analyzed result #### Expect array(0, false, array('foo')) when input array('flags' => array('spvar' => 0)), array(0, 'foo') array(1, false, array('foo')) when input array('flags' => array('spvar' => 0)), array(1, 'foo')
`public static string` | # `toString( integer $levels, boolean $spvar, array<string|integer> $var )` get normalized handlebars expression for a variable get normalized handlebars expression for a variable #### Parameters $levels trace N levels top parent scope $spvar is the path start with @ or not $var variable parsed path #### Returns string normalized expression for debug display #### Expect '[a].[b]' when input 0, false, array('a', 'b') '@[root]' when input 0, true, array('root') 'this' when input 0, false, null 'this.[id]' when input 0, false, array(null, 'id') '@[root].[a].[b]' when input 0, true, array('root', 'a', 'b') '../../[a].[b]' when input 2, false, array('a', 'b') '../[a\'b]' when input 1, false, array('a\'b')