RestApiResponse: add getSingleResult, split getResult

This commit is contained in:
Thomas Gelf 2015-12-02 02:40:53 +01:00
parent a94f5c5969
commit 81a1706b46
1 changed files with 11 additions and 1 deletions

View File

@ -26,9 +26,19 @@ class RestApiResponse
}
public function getResult($desiredKey, $filter = array())
{
return $this->extractResult($this->results, $desiredKey, $filter);
}
public function getSingleResult()
{
return $this->results[0]->result;
}
protected function extractResult($results, $desiredKey, $filter = array())
{
$response = array();
foreach ($this->results as $result) {
foreach ($results as $result) {
foreach ($filter as $key => $val) {
if (! property_exists($result, $key)) {
continue;