User: add __toString() magic method
This commit is contained in:
parent
a4d2e3369c
commit
33fcd6a92c
2 changed files with 11 additions and 1 deletions
|
@ -83,4 +83,14 @@ class User {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method to allow pretty cast to string
|
||||
* @return string
|
||||
*/
|
||||
public function __toString() {
|
||||
if (isset($this -> name))
|
||||
return sprintf('%s (%s)', $this -> name, $this -> username);
|
||||
return $this -> namename;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ class Log {
|
|||
$_SERVER['REMOTE_ADDR'],
|
||||
);
|
||||
if (Auth::enabled())
|
||||
$msg[] = (Auth::user()?Auth::user()->username:'anonymous');
|
||||
$msg[] = (Auth::user()?Auth::user():'anonymous');
|
||||
$msg[] = $level;
|
||||
$msg[] = $message;
|
||||
$msg = implode(' - ', $msg)."\n";
|
||||
|
|
Loading…
Reference in a new issue