Created
December 3, 2011 02:33
-
-
Save raphaeldealmeida/1425813 to your computer and use it in GitHub Desktop.
Exemplo Traits
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 | |
trait SomeClass { | |
public function add($x, $y) { return $x + $y; } | |
} | |
class TestComponent { | |
use SomeClass; | |
} | |
$test_comp = new TestComponent(); | |
$test_comp->add(2, 5); |
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 SomeClass extends CBehavior | |
{ | |
public function add($x, $y) { return $x + $y; } | |
} | |
$test_comp = new TestComponent(); | |
$test_comp->attachbehavior('blah', new SomeClass); | |
$test_comp->add(2, 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment