Posts Tagged ‘fluent interface’

Fluent Arrays and Strings in PHP – Adding JSON and more

Friday, July 11th, 2008

Recently I’ve had the need to extend the interface further, among other things with JSON support. I’ve used code published by Nicolas Crovatti to do this. There was one line in there though that wasn’t consistent with its purpose. If you use that code you have to replace if($i != $keys[$i]) with if($i !== $keys[$i]). On the other hand if you use PHP >= 5.2 you don’t need this function at all, you use json_encode instead.... Read More

Fluent Arrays and Strings in PHP

Monday, June 23rd, 2008

I’ve been working some with jQuery and Ruby lately, as you might know they both have very neat fluent interfaces for writing short and easily understandable code. Especially Ruby’s array and string handling should be something that can be done in PHP so I started googling for something nice but so far the best I’ve been able to find is pooQuery. Update: Apparently pooQuery really is a joke (see the comments at the bottom of this post), anyway here is an example from it of how fluent stuff can go too far: ... Read More