Created
April 20, 2011 14:24
-
-
Save alganet/931458 to your computer and use it in GitHub Desktop.
Simple chain sample for a friend
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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