Getting Started
How to install it and play with it while coding. Basic rules to know.
How to install it and play with it while coding. Basic rules to know.
Classes are defined into namespace \Malenki\Bah
.
Each class is named by the first letter of its representing type. So, for string, class is named S
, for array it is A
, hash is H
, number is N
and character is C
.
Methods return either current object, other Bah object or boolean.
Methods are in camel cases like defined into PSR1.
But I try to use shorter possible name, avoiding get prefix and all sort of this. Get Prefix is useless because classes are get centric, their goal is to return something, seting value is done while instanciating object. Exception is for A and H classes, because you can change value of some item, that’s all. So no get prefix, because no set!
Magic getters are often used into Bah. Naming convention is defined as follow:
_
)Bah allow you to export each object as PHP primitive type using magic getters. So, to export S object as string, do $mySObject->string
Project is available on Packagist, so, you can install it using Composer.
You have just to do a composer require malenki/bah:0.9.3
to install version 0.9.3 into your project.
You can clone Github repository where Bah is hosted. Just do git clone https://github.com/malenkiki/bah.git
Now you have the lib, you can start using it!
Bah uses composer, so, you must add somewhere into yoour code a line to include the autoloader provided by composer:
include('/path/to/verdor/autoloader.php');
Then, you can start using its classes! For exemple, let’s use S class:
include('/path/to/verdor/autoloader.php');
use \Malenki\Bah\S;
$s = new S('J’aime beaucoup coder avec Bah!');
echo $s->upper->prepend(' ')->times(3)->lstrip;
This previous example converts the string into upper cases, adds at its start a space, then copies 3 times the resulting string and then removes blank character at the left.
Unit testing is available on this project. This uses Phpunit, and tests are into directory… tests/
:-)
A configuration file is at the root of source's tree, so you can run test just by lauching phpunit without arguments.
Please submit your issues or requests into the issue tracking tool provided by Github.
Please also select right tag prposed by Github.
Before submit a pull request, you must check whether your code pass unit tests and you must provide new unit tests for the new code.
To realize pull request, you must have an account on Github, fork my project and the write your pull request.