Skip to content

Commit

Permalink
Extract 'loadAttributes' method.
Browse files Browse the repository at this point in the history
  • Loading branch information
DFurnes committed Jul 20, 2020
1 parent 754d92f commit 30b6141
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/Server/RemoteUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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;
}
}

0 comments on commit 30b6141

Please sign in to comment.