firstname.lastname@example.org (Arno Zijlstra) napisał interesujący post:
With the introduction of chaining methods together in PHP 5 we now have the opportunity to implement Fluent Interfaces in PHP which opens up an interesting way of writing more readable and smaller code.
Fluent Interfaces are not a new programming construct, they provide us with the ability to directly de-reference an object, PHP developers can build objects using fluent interfaces.
On the first look this might look like abracadabra if you are totally new to the new buzzword “Fluent Interfaces”. Fluent interfaces are best described as way of chaining methods of an object together. By having a method return a reference to the object itself, return $this; you chain methods together like this:
The point of using fluent interfaces is simple; to make your code easier to read (and in the end also easier to maintain). My interest has been triggered by the articles Júlio Pontes has been posting on the All […]
Czytaj dalszą część postu