Auth\User: add __set() method
This commit is contained in:
parent
b9a5a60dc9
commit
37eab5d49f
1 changed files with 23 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
||||||
namespace EesyPHP\Auth;
|
namespace EesyPHP\Auth;
|
||||||
|
|
||||||
use EesyPHP\Log;
|
use EesyPHP\Log;
|
||||||
|
use function EesyPHP\ensure_is_array;
|
||||||
|
|
||||||
class User {
|
class User {
|
||||||
|
|
||||||
|
@ -58,6 +59,28 @@ class User {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to set a dynamic property
|
||||||
|
* @param string $key The property
|
||||||
|
* @param mixed $value The value
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __set($key, $value) {
|
||||||
|
switch ($key) {
|
||||||
|
case 'username':
|
||||||
|
$this -> username = strval($value);
|
||||||
|
break;
|
||||||
|
case 'backend':
|
||||||
|
$this -> backend = strval($value);
|
||||||
|
break;
|
||||||
|
case 'info':
|
||||||
|
$this -> info = ensure_is_array($value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this -> info[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic method to check if a dynamic property is set
|
* Magic method to check if a dynamic property is set
|
||||||
* @param string $key The property
|
* @param string $key The property
|
||||||
|
|
Loading…
Reference in a new issue