View Source PhpAssocMap.Utils (PhpAssocMap v3.0.0)
Helper functions to work with strings
Summary
Functions
Converts a key and a value into an associative array association using arrow
Convert a string for a literal string by escaping quotes and wrapping into them
Wraps a value inside specified string.
Types
Functions
Converts a key and a value into an associative array association using arrow
Exemples
iex> PhpAssocMap.Utils.associate("my_key", "Some value")
"'my_key'=>'Some value'"
Convert a string for a literal string by escaping quotes and wrapping into them
Exemples
iex> PhpAssocMap.Utils.stringify("Jon's")
"'Jon\\'s'"
iex> PhpAssocMap.Utils.stringify(true)
"true"
iex> PhpAssocMap.Utils.stringify(24)
"24"
iex> PhpAssocMap.Utils.stringify(24.10)
"24.1"
iex> PhpAssocMap.Utils.stringify(nil)
"null"
iex> PhpAssocMap.Utils.stringify(:open_bracket)
"["
Wraps a value inside specified string.
Using wrap/2 will wrap both end using the same string. Using the wrap/3 will wrap left with second parameter and right with third
Exemples
iex> PhpAssocMap.Utils.wrap("house", "*")
"*house*"
iex> PhpAssocMap.Utils.wrap("house", "{", "}")
"{house}"