Skip to content

Instantly share code, notes, and snippets.

@raphaeldealmeida
Created December 3, 2011 02:33
Show Gist options
  • Save raphaeldealmeida/1425813 to your computer and use it in GitHub Desktop.
Save raphaeldealmeida/1425813 to your computer and use it in GitHub Desktop.
Exemplo Traits
<?php
trait SomeClass {
public function add($x, $y) { return $x + $y; }
}
class TestComponent {
use SomeClass;
}
$test_comp = new TestComponent();
$test_comp->add(2, 5);
<?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