Skip to content

Instantly share code, notes, and snippets.

@alganet
Created April 20, 2011 14:24
Show Gist options
  • Select an option

  • Save alganet/931458 to your computer and use it in GitHub Desktop.

Select an option

Save alganet/931458 to your computer and use it in GitHub Desktop.
Simple chain sample for a friend
<?php
class Chain
{
public static function foo() {
echo "foo\n";
return new Chain; //or return new static;
}
public function bar()
{
echo "bar\n";
return $this;
}
public function baz()
{
echo "baz\n";
return $this;
}
}
Chain::foo()->bar()->baz();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment