Compare
Helper class to compare two dictionaries.
Can be used to determine which keys/values are missing from a dictionary (right) compared to a base directory (left).
Tags
Table of Contents
dictionaries() | Compares keys and values from left dictionary against right dictionary and returns the difference. | string[] |
---|---|---|
dictionariesKeys() | Compares keys from left dictionary against right dictionary. | string[] |
dictionariesValues() | Compares values from left dictionary against right dictionary to find same values. | string[] |
dictionariesEmptyValues() | Returns all keys for which the value is empty. | string[] |
undot() | Transfer dot notation associative array back into multidimentional associative array. | array |
Methods
dictionaries()
Compares keys and values from left dictionary against right dictionary and returns the difference.
public
static dictionaries(
$leftDictionary :
DictionaryInterface
, $rightDictionary :
DictionaryInterface
[, $undot :
bool
= false ]
)
: string[]
Parameters
- $leftDictionary : DictionaryInterface
- $rightDictionary : DictionaryInterface
- $undot : bool = false
If true, return the dot notation associative array. If false, returns the normal multidimensional associative array [Default: true]
Return values
string[]dictionariesKeys()
Compares keys from left dictionary against right dictionary.
public
static dictionariesKeys(
$leftDictionary :
DictionaryInterface
, $rightDictionary :
DictionaryInterface
)
: string[]
Returns a list of keys present in the left dictory, but not found in the right one. Can be used to sync both dictionary content.
Parameters
- $leftDictionary : DictionaryInterface
- $rightDictionary : DictionaryInterface
Return values
string[] —List of keys
dictionariesValues()
Compares values from left dictionary against right dictionary to find same values.
public
static dictionariesValues(
$leftDictionary :
DictionaryInterface
, $rightDictionary :
DictionaryInterface
[, $undot :
bool
= false ]
)
: string[]
Returns a list of values which are the same in both dictionaries. Can be used to find all values in the right directory that might not have been translated compared to the left one. For example, when comparing french and english dictionaries, this can be used to return all English values present in the French dictionary.
Parameters
- $leftDictionary : DictionaryInterface
- $rightDictionary : DictionaryInterface
- $undot : bool = false
If true, return the dot notation associative array. If false, returns the normal multidimensional associative array [Default: false]
Return values
string[]dictionariesEmptyValues()
Returns all keys for which the value is empty.
public
static dictionariesEmptyValues(
$dictionary :
DictionaryInterface
)
: string[]
Can be used to find all keys that needs to be translated in the dictionary.
Parameters
- $dictionary : DictionaryInterface
Return values
string[] —List of keys
undot()
Transfer dot notation associative array back into multidimentional associative array.
protected
static undot(
$array :
array
)
: array
Parameters
- $array : array