wpfulcrum / extender
Fulcrum Extender Module - extending the PHP array and string functionality + goodies for WordPress too.
Requires
- php: >=5.6
Requires (Dev)
- brain/monkey: ^2.0
- mockery/mockery: ~0.9
- phpunit/phpunit: ~4.8|~5.7.9
- sensiolabs/security-checker: ^4.0
- squizlabs/php_codesniffer: ^3.0
README
The Fulcrum Extender module - extending the PHP array, PHP strings, and WordPress functionality.
- Array Module - making it easier to work with PHP arrays, especially deeply nested array. It includes "dot" notation.
- String Module - providing the missing PHP string functionality
- WP Module - providing some missing WordPress functionality
Array Module
Working with arrays is tedious, especially deeply nested arrays. This module provides a handful of useful functions including borrowing from Laravel's "dot" notation.
"Dot" Notation
Dot notation is a clever mechanism to access deeply nested arrays using a string of the keys separated by dots.
For example, let's say you have a deeply nested array like this one:
$user = array(
'user_id' => 504,
'name' => 'Bob Jones',
'social' => array(
'twitter' => '@bobjones',
),
'languages' => array(
'php' => array(
'procedural' => true,
'oop' => false,
),
'javascript' => true,
'ruby' => false,
),
);
To drill down to Bob's twitter handle, you'd pass 'social.twitter'
and to get to whether he likes OOP or procedural, you'd pass 'languages.php.oop'
or 'languages.php.procedural'
.
Credit: Taylor Otwell brought us "dot" notation in the Laravel framework. Using his concept, Fulcrum adapts it to fit WordPress running on PHP 5.6 and up.
Array Extender Functions
Each of these functions is documented in the Wiki.
* indicates this function works with "dot notation".
String Module
We often need functionality to test if a string has, starts with, or ends with a character or substring. This module includes functionality for checking, converting, and truncating strings.
Each of these functions is documented in the Wiki.
WordPress Module
We often need extra functionality to make our jobs easier when working with WordPress. This module adds functionality for checking, getting, and preparing.
Each of these functions is documented in the Wiki.
Contributing
All feedback, bug reports, and pull requests are welcome.