neoan3-apps / ops
neoan3 common string operations helper class
Requires
- ext-dom: *
- ext-json: *
- ext-mbstring: *
- ext-openssl: *
- neoan3-apps/template: ^1
Requires (Dev)
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2024-11-20 01:42:11 UTC
README
Ops provides valuable string helpers for everyday use ranging from simple templating to encryption & hash generation.
This library facilitates
Templating
Templating has grown into a dedicated repository and is now available at neoan3-apps/template. For the time being, Ops will inherit functions as if it where part of Ops. However, in new projects we recommend using "Template" instead of "Ops" to trigger templating functionality.
String manipulation
serialize($any)
Serializes strings, arrays and objects (url save).
unserialize($serializedString)
Reverts serialize()
pin($length)
Returns a random integer in the requested length.
flattenArray($array)
Converts deep arrays to keyed arrays of one level to resemble JS-object selection.
$original = ['items' => ['name' => 'sam']]; $flat = Ops::flattenArray($original); /* * output $flat: ['items.name' => 'sam']; * */
randomString($length = 10)
Returns a random string (with or without special characters) in the requested length.
encrypt($string, $key)
Encrypts a string with a symmetric AES-256 algorithm.
decrypt($encrypted, $key)
Decrypts a string with a symmetric AES-256 algorithm.
extrude($targets,$array)
Returns selected part of $array.
$userInput = [ 'id'=>1, 'name'=>'sam', 'random'=>'value' ]; $clean = Ops::extrude(['id','name'],$userInput); // Output $clean: ['id'=>1,'name'=>'sam']
toPascalCase($string)
Converts spaces, snake-, kebab- or camelCase to PascalCase
toCamelCase($string)
Converts spaces, snake-, kebab- or PascalCase to camelCase
toSnakeCase($string)
Converts spaces, camel-, kebab- or PascalCase to snake_case
toKebabCase($string)
Converts spaces, camel-, snake- or PascalCase to kebab-case