Skip to content

Instantly share code, notes, and snippets.

@wowo
Created February 9, 2012 22:13
Show Gist options
  • Save wowo/1783717 to your computer and use it in GitHub Desktop.
Save wowo/1783717 to your computer and use it in GitHub Desktop.
<?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