Constants

VAR_PATTERN

VAR_PATTERN

Pattern of a variable

EXTRA_VAR_PREFIX

EXTRA_VAR_PREFIX

Prefix of the extra variables to avoid conflicts

Properties

$varPregPattern

$varPregPattern : string

Pattern to match variables

Type

string

Methods

fetch()

fetch(string  $basePath) : mixed

Return value in depth from multidimensional array

Parameters

string $basePath

Something like: value.in.the.depth

Returns

mixed —

Result value

merge()

merge(array  $array) : $this

Parameters

array $array

Returns

$this

unsetKeys()

unsetKeys(array  $keys) : $this

Parameters

array $keys

Returns

$this

getVarTranslation()

getVarTranslation() : $this

Returns

$this

makeExtraVarKey()

makeExtraVarKey(string  $varKey) : string

Parameters

string $varKey

Returns

string

makeVar()

makeVar(string  $key) : string

Transform varName into {$varName}.

Parameters

string $key

Returns

string

makeVarKeys()

makeVarKeys(\ArrayAccess  $subject = null) : \ArrayAccess|self

Transform subject keys to {$var} like

Parameters

\ArrayAccess $subject

Returns

\ArrayAccess|self

getVarPregPattern()

getVarPregPattern() : string

Match {$var} regular pattern

Returns

string

containsVar()

containsVar(string  $string) : boolean

Return true if {$var} is in the string

Parameters

string $string

Returns

boolean

removeVars()

removeVars(string  $string) : boolean

Remove vars from string

Parameters

string $string

Returns

boolean

translateString()

translateString(string  $str) : mixed

Replace {$var} in string with data from translation

If $str = {$var} and translation has item with key {$var} = array, immediately return this array.

Parameters

string $str

Returns

mixed

translate()

translate(string|array  $subject) : $this

Replace {$var} in $subject with data from $translation

Parameters

string|array $subject

Returns

$this

mergeValues()

mergeValues(array  $values) : $this

Parameters

array $values

Returns

$this

setDefaults()

setDefaults(array  $defaults) : array

Set translated defaults into translation

Parameters

array $defaults

Returns

array

fetchVars()

fetchVars(array  $options) : $this

Fetch custom variables into translation

example of properties:

$translation = [
    'value' => [
        'in' => [
            'the' => [
                'depth' => 'valueInTheDepth',
            ],
        ],
    ],
];

example of options:

$options = [
    'customVar' => 'value.in.the.depth',
];

Parameters

array $options

Returns

$this

pushVars()

pushVars(array  $options, self  $translation = null) : $this

Push variables into translation

Parameters

array $options
self $translation

Returns

$this

setDefault()

setDefault(mixed  $key, mixed  $value) : $this

Parameters

mixed $key
mixed $value

Returns

$this

resolveBasePathParts()

resolveBasePathParts(string  $basePath) : array

Explode path by dots and return those parts

Parameters

string $basePath

Returns

array