Class which can be used to easily modify serializations and arrays.
More...
|
| setArrayValueAtKey (array &$array, $path, $value) |
|
| getElementsMatchingPath (array $array, array $pathElements, $currentPath='') |
| Method to get elements that match the path given. More...
|
|
| getElementsForAllKeys (array $array, array $pathElements, $currentPath) |
|
| getElementsForKey (array $array, array $pathElements, $currentPath, $key) |
|
| getJoinedPath ( $prefix, $key) |
|
| getPathParts ( $path) |
|
Class which can be used to easily modify serializations and arrays.
This could easily be factored out into a library.
- Copyright
- GPL-2.0-or-later
- Author
- Addshore
◆ getElementsForAllKeys()
Wikibase\Lib\Serialization\SerializationModifier::getElementsForAllKeys |
( |
array |
$array, |
|
|
array |
$pathElements, |
|
|
|
$currentPath |
|
) |
| |
|
private |
- Parameters
-
array | $array | |
string[] | $pathElements | |
string | $currentPath | |
- Returns
- array
◆ getElementsForKey()
Wikibase\Lib\Serialization\SerializationModifier::getElementsForKey |
( |
array |
$array, |
|
|
array |
$pathElements, |
|
|
|
$currentPath, |
|
|
|
$key |
|
) |
| |
|
private |
- Parameters
-
array | $array | |
string[] | $pathElements | |
string | $currentPath | |
string | $key | |
- Returns
- array
◆ getElementsMatchingPath()
Wikibase\Lib\Serialization\SerializationModifier::getElementsMatchingPath |
( |
array |
$array, |
|
|
array |
$pathElements, |
|
|
|
$currentPath = '' |
|
) |
| |
|
private |
Method to get elements that match the path given.
This is called recursively along with getElementsForAllKeys and getElementsForKey The number of calls depends on the depth of the array.
- Parameters
-
array | $array | |
string[] | $pathElements | |
string | $currentPath | |
- Returns
- array
◆ getJoinedPath()
Wikibase\Lib\Serialization\SerializationModifier::getJoinedPath |
( |
|
$prefix, |
|
|
|
$key |
|
) |
| |
|
private |
◆ getPathParts()
Wikibase\Lib\Serialization\SerializationModifier::getPathParts |
( |
|
$path | ) |
|
|
private |
- Parameters
-
- Returns
- string[]
◆ modifyUsingCallback()
Wikibase\Lib\Serialization\SerializationModifier::modifyUsingCallback |
( |
array |
$array, |
|
|
|
$path, |
|
|
|
$callback |
|
) |
| |
- Parameters
-
array | $array | the array to modify |
null | string | $path | the path that we want to modify. Element keys should be separated with / characters.
- characters can be used to match all keys at a given level. null can be used to modify $array directly. Examples: null 'foo/*' 'root/entities/*\/statement/references/*\/snaks/*'
|
callable | $callback | Callback accepts 1 parameter which is the element to touch Callback should return the altered element |
- Returns
- array the altered array
◆ setArrayValueAtKey()
Wikibase\Lib\Serialization\SerializationModifier::setArrayValueAtKey |
( |
array & |
$array, |
|
|
|
$path, |
|
|
|
$value |
|
) |
| |
|
private |
- Parameters
-
array | $array | |
string | $path | |
mixed | $value | |
The documentation for this class was generated from the following file: