diff --git a/src/Server/RemoteUser.php b/src/Server/RemoteUser.php index 69aa424..f76c818 100644 --- a/src/Server/RemoteUser.php +++ b/src/Server/RemoteUser.php @@ -59,10 +59,7 @@ public function __get($key) // duration of this request. (This instance is kept by the // user provider.) if (! $this->loaded) { - $user = gateway('northstar')->withToken($this->token)->getUser($this->id); - - $this->attributes = $user->toArray(); - $this->loaded = true; + $this->loadAttributes(); } if (array_key_exists($key, $this->attributes) || $this->hasGetMutator($key)) { @@ -71,4 +68,18 @@ public function __get($key) return null; } + + /** + * Load the attributes on this 'RemoteUser' by requesting + * the corresponding user profile in Northstar. + * + * @return void + */ + private function loadAttributes() + { + $user = gateway('northstar')->withToken($this->token)->getUser($this->id); + + $this->attributes = $user->toArray(); + $this->loaded = true; + } }