Skip to content

Commit

Permalink
Initialize currentUser and search api only once for every Github inst…
Browse files Browse the repository at this point in the history
…ance
  • Loading branch information
Marc Philip Scholten committed Mar 13, 2014
1 parent be5ac7a commit 65629b5
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Github.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class Github
{
private $client;

private $currentUser;
private $search;

/**
* @see Github::create()
*
Expand Down Expand Up @@ -76,17 +79,23 @@ public static function create($authenticationMethod = null, $cachePath = null)
*/
public function getCurrentUser()
{
$api = new CurrentUser($this->client);
return $api;
if ($this->currentUser === null) {
$this->currentUser = new CurrentUser($this->client);
}

return $this->currentUser;
}

/**
* @return Search
*/
public function getSearch()
{
$api = new Search($this->client);
return $api;
if ($this->search === null) {
$this->search = new Search($this->client);
}

return $this->search;
}

/**
Expand Down

0 comments on commit 65629b5

Please sign in to comment.