DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Ninging It

02.17.2006
| 1975 views |
  • submit to reddit
        I love http://www.ning.com/ - and I fell in love with chaining whole bunches of objects together.


class Foo {
    function transform() {
         //Some actual code
         return $this;
    }

    function transform2() {
         //Some actual code
         return $this;
    }

}

$f = new Foo();
$f->transform()->transform2()->transform();

Concise!    

Comments

Snippets Manager replied on Fri, 2006/02/10 - 8:57pm

It's cool isn't it? If you like this and are ready for a head-rush, go check out the chaining and nesting of array indexors in my random password generator script: http://www.bigbold.com/snippets/posts/show/1487