“Belt” adds very clever everyday functions to PHP, comes with JavaScript naming styles and eventually solves the needle/haystack problem

This little projects is basically super-simple, but somehow really really clever and definitly a time-saver: Belt is a typical Composer-loaded dependency that adds a lot of useful functions “to PHP”. Some of these functions are more or less duplicates of already existing one in native PHP, buuuut they solve the common unsteady needle / haystack vs. haystack /needle parameter-order problem in PHP (and narrow to the beautiful Java / JavaScript function/method naming convention). A very interesting project, hopefully with a great future! Let’s see some examples (some examples show callable code, some show method definitions):
// returns the max value of an array
Belt::max([1, 2, 3]); // => 3
// checks if arguments are equal
Belt::isEqual("yeah", "nope"); // => false
// flattens a multi-dimensional array
Belt::flatten([1, [2, [3]]]) // => [1, 2, 3]
// create an array containing a range of elements, optional with steppings
Belt::range(1, 10, 2); // => 1, 3, 5, 7, 9
// returns an array containing the unique items in both arrays
union($array1, $array2)
// execute $closure only once and ignore future calls [interesting stuff!]
once(Closure $closure)
// only execute $closure after the exact $number of failed tries
after($number, Closure $closure)
// escape all HTML entities in a string
escape($string)
// invoke a $closure $number of times
times($number, Closure $closure)
// iterate through $collection using $iterator
each(array $collection, Closure $iterator)
// convert $value to an array
toArray($value)
// group values in $collection by $iterator's return value
groupBy(array $collection, Closure $iterator)
// determine whether the given object has a key
has($object, $key)
// copy all properties from $source to $destination
extend($source, $destination)
// fill in any missing values using $defaults
defaults($object, $defaults)
// determine whether the given value is a float or an integer
isNumber($value)
Link: Belt on GitHub