Proposal for "Flu"

» Metadata » Status
  • Status: Draft
» Description
The main concept is to provide fluent-interfaces functionality for PHP.

Example first:

If you want some string to:

1. be trimmed,
2. be lowercased,
3. be cut down to first 3 characters,
4. be padded with asterisks to 10 characters at right,
5. have all spacebars replaced by underscores

you have to write something like this:


$str2 = str_replace(' ', '_', str_pad(substr(strtolower(trim($str1)), 0, 3), 10, '*'));



With this package you should be able to write something like this:


$str2 = flu::init($str2)->trim()->toLower()->substr(0, 3)->pad(10, '*')->replace(' ', '_');


Looks much better, right? ;)
My target here is to write library for "transforming" (with some contrains) PHP functions into methods. I'd also like to provide command-line generator for creating new function wrappers.
» Dependencies » Links
  • PHP >= 5.2.0
» Timeline » Changelog
  • First Draft: 2008-10-08