Forget primitive types in PHP!

PHP becomes better every day, but some bad things aren’t go away. One of this is the primitive type, not available as object.

This librairy avoids this by allowing use of objects for string, character, array, hash and number.

Download
0.9.4
Fork Me!
on Github

Intuitive

Lot of features have several name and call ways, so, you have less surprise when coding with it!

Easy

Designed to be easy to install and use. Install it using Git, Composer or zip. Code with it using chaining methods and lot of alias and magic getters.

Open

MIT-Licensed, source code is on Github and CI is on Travis, so you can use it, check it and enhance it!


Short Class name Use them with one letter!

To be used in place of primitive type, classe's names must be short, very short. So, just declare class to use at the start, and then use only one letter! S for string, C for character, A for array, H for name-index array (hash) and N for numeric values.


use \Malenki\Bah\S; // For string
use \Malenki\Bah\C; // For one char string
use \Malenki\Bah\A; // For array
use \Malenki\Bah\H; // For name-indexed array
use \Malenki\Bah\N; // For numeric values
            

Chaining To make your path into the code!

Unless exceptions, all methods are chainable, so you can return each type of Bah after each method call, and avoid use of lot of transition variables!


use \Malenki\Bah\S;
$s = new S('This is a string!');
// print '    THIS    '
echo $s->upper->sub(4)->center(12);
        

UTF-8 Only Ready for international!

Use old page encoding like iso-8859-15 and its friends it is very bad idea since some years, so, Bah! discourages the use of this dinosaurs by forcing you to use UTF-8 only! This is visible for example into C class.


use \Malenki\Bah\C;
$c = new C('œ');
// Print the unicode block name
echo $c->block;
        

Less parenthesis Use them only when needed

A lot of methods have not params or take a default one. So, for this, magic getters are enough, no need to put parenthesis when it is not needed!


use \Malenki\Bah\A;
$a = new A(array('un', 'deux', 'trois', 'quatre'));
echo $a->join->upper->length;
// print 17;