-
-
Save geofmureithi-zz/28cb9675d76f70744c098fdb5d15fba3 to your computer and use it in GitHub Desktop.
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 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