Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sroehrl/neoan3-ops
Common String operations helper
https://github.com/sroehrl/neoan3-ops
Last synced: 10 days ago
JSON representation
Common String operations helper
- Host: GitHub
- URL: https://github.com/sroehrl/neoan3-ops
- Owner: sroehrl
- License: mit
- Created: 2018-12-09T17:14:57.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-10-19T19:19:02.000Z (about 3 years ago)
- Last Synced: 2024-08-05T09:12:03.226Z (4 months ago)
- Language: PHP
- Homepage:
- Size: 44.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# neoan3-ops
[![Build Status](https://travis-ci.com/sroehrl/neoan3-ops.svg?branch=master)](https://travis-ci.com/sroehrl/neoan3-ops)
[![Test Coverage](https://api.codeclimate.com/v1/badges/73cacbc29aa1438b37fd/test_coverage)](https://codeclimate.com/github/sroehrl/neoan3-ops/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/73cacbc29aa1438b37fd/maintainability)](https://codeclimate.com/github/sroehrl/neoan3-ops/maintainability)Ops provides valuable string helpers for everyday use ranging from simple templating to encryption & hash generation.
This library facilitates
- [templating](#templating)
- [string-manipulation](#string-manipulation)## Templating
Templating has grown into a dedicated repository and is now available at [neoan3-apps/template](https://github.com/sroehrl/neoan3-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.
```PHP
$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.
```PHP
$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