diff --git a/src/Auth/AuthedUser.php b/src/Auth/AuthedUser.php index afafbb2..04eb8bb 100644 --- a/src/Auth/AuthedUser.php +++ b/src/Auth/AuthedUser.php @@ -11,9 +11,9 @@ public function __construct( $username = null, $userId = 0, array $properties = [] ) { - $this->_data['userId'] = $userId; + $this->_data['userId'] = $userId; $this->_data['username'] = $username; - $this->_data['data'] = $properties; + $this->_data['data'] = $properties; } protected function _getData($key, $default = null) @@ -55,12 +55,30 @@ public function getProperty($key, $default = null) return isset($data[$key]) ? $data[$key] : $default; } + /** + * Set a cached property on the authed user + * + * @param $key + * @param $value + * + * @return $this + */ public function setProperty($key, $value) { $this->_data['data'][$key] = $value; return $this; } + /** + * Get all cached properties + * + * @return array + */ + public function getProperties() + { + return (array)$this->_data; + } + /** * @return string Serialized representation of the authed user */ @@ -81,7 +99,7 @@ public function unserialize($data) $json = json_decode($data); if(json_last_error() === JSON_ERROR_NONE) { - $this->_data = (array)$json; + $this->_data = (array)$json; $this->_data['data'] = ValueAs::arr($this->_data['data'], []); } else diff --git a/src/Auth/IAuthedUser.php b/src/Auth/IAuthedUser.php index c4677d4..44f3ea8 100644 --- a/src/Auth/IAuthedUser.php +++ b/src/Auth/IAuthedUser.php @@ -27,6 +27,13 @@ public function getUsername(); */ public function getProperty($key, $default = null); + /** + * Get all cached properties + * + * @return array + */ + public function getProperties(); + /** * @return string Serialized representation of the authed user */