Created
February 9, 2012 22:13
-
-
Save wowo/1783717 to your computer and use it in GitHub Desktop.
This file contains 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 Loggable { | |
public function log($event) { | |
printf("Event: '%s', source: '%s'\n", | |
event, get_class($this)); | |
} | |
} | |
class User { | |
use Loggable; | |
public function something() { | |
$this->log("Something happened"); | |
} | |
} | |
$u = new User; | |
$u->something(); | |
// will echo: | |
// Event: 'Something happened', source: 'User' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment