Skip to content

Commit

Permalink
Modified get() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Bean committed Jul 29, 2010
1 parent 13343e6 commit cdcca30
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
12 changes: 8 additions & 4 deletions src/base.php
Expand Up @@ -19,9 +19,13 @@ class Base
* @return void
* @author Martin Bean <martin@digitalpop.co.uk>
**/
public function get($url)
public function get($url, $options=array())
{
return json_decode(file_get_contents($this->baseUrl.$url));
$url = $this->baseUrl . $url;
if (!empty($options)) {
$url.= "?" . http_build_query($options);
}
return json_decode(file_get_contents($url));
}

/**
Expand All @@ -31,8 +35,8 @@ public function get($url)
* @param array $options
* @return string
**/
public function paginated_list($url, $options)
public function paginated_list($object)
{
return json_decode(file_get_contents($this->baseUrl.$url.'?'.http_build_query($options)));
return json_decode(file_get_contents($object));
}
}
4 changes: 2 additions & 2 deletions src/player.php
Expand Up @@ -26,7 +26,7 @@ function find($id)
**/
public function shots($page=null, $per_page=null)
{
return $this->paginated_list('/players/'.$this->id.'/shots', array($page, $per_page));
return $this->paginated_list($this->get('/players/'.$this->id.'/shots', array($page, $per_page)));
}

/**
Expand All @@ -38,6 +38,6 @@ public function shots($page=null, $per_page=null)
**/
public function everyone($page=null, $per_page=null)
{
return $this->paginated_list('/players/'.$this->id.'/shots/following', array($page, $per_page));
return $this->paginated_list($this->get('/players/'.$this->id.'/shots/following', array($page, $per_page)));
}
}
6 changes: 3 additions & 3 deletions src/shot.php
Expand Up @@ -26,7 +26,7 @@ function find($id)
**/
public function debuts($page=null, $per_page=null)
{
return $this->paginated_list('/shots/debuts', array($page, $per_page));
return $this->paginated_list($this->get('/shots/debuts', array($page, $per_page)));
}

/**
Expand All @@ -38,7 +38,7 @@ public function debuts($page=null, $per_page=null)
**/
public function everyone($page=null, $per_page=null)
{
return $this->paginated_list('/shots/everyone', array($page, $per_page));
return $this->paginated_list($this->get('/shots/everyone', array($page, $per_page)));
}

/**
Expand All @@ -50,6 +50,6 @@ public function everyone($page=null, $per_page=null)
**/
public function popular($page=null, $per_page=null)
{
return $this->paginated_list('/shots/popular', array($page, $per_page));
return $this->paginated_list($this->get('/shots/popular', array($page, $per_page)));
}
}

0 comments on commit cdcca30

Please sign in to comment.