RestApiResponse: add getSingleResult, split getResult
This commit is contained in:
parent
a94f5c5969
commit
81a1706b46
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue