Compare commits
4 commits
6873a7e2a0
...
a4e21e6046
Author | SHA1 | Date | |
---|---|---|---|
|
a4e21e6046 | ||
|
a74c23fcd0 | ||
|
d42a864901 | ||
|
b33a3e8205 |
1 changed files with 42 additions and 5 deletions
|
@ -7,7 +7,7 @@ use EesyPHP\Log;
|
|||
use function EesyPHP\ensure_is_array;
|
||||
use function EesyPHP\vardump;
|
||||
|
||||
class User {
|
||||
class User implements \ArrayAccess {
|
||||
|
||||
/**
|
||||
* Username
|
||||
|
@ -111,10 +111,47 @@ class User {
|
|||
/**
|
||||
* ArrayAccess interface
|
||||
*/
|
||||
public function offsetExists($offset) { return self :: __isset($offset); }
|
||||
public function offsetGet($offset){ return self :: __get($offset); }
|
||||
public function offsetSet($offset, $value) { self :: __set($offset, $value); }
|
||||
public function offsetUnset($offset) { self :: __set($offset, null); }
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
/**
|
||||
* Magic method to check if an dynamic property exist when object is used as an array
|
||||
* @param string $offset The property
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists($offset) {
|
||||
return $this -> __isset($offset);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
/**
|
||||
* Magic method to get a dynamic property when object is used as an array
|
||||
* @param string $offset The property
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($offset){
|
||||
return $this -> __get($offset);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
/**
|
||||
* Magic method to set a dynamic property when object is used as an array
|
||||
* @param string $offset The property
|
||||
* @param mixed $value The value
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value) {
|
||||
$this -> __set($offset, $value);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
/**
|
||||
* Magic method to unset (=set as null) a dynamic property when object is used as an array
|
||||
* @param string $offset The property
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset) {
|
||||
$this -> __set($offset, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check user password
|
||||
|
|
Loading…
Reference in a new issue