Skip to content

Commit 0b7bab6

Browse files
committed
return object instead of array
1 parent 8959242 commit 0b7bab6

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

lib/Checkfront.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,27 @@ private function tokens($data=array()) {
379379
}
380380

381381

382+
function _array_to_obj($array, &$obj)
383+
{
384+
foreach ($array as $key => $value)
385+
{
386+
if (is_array($value)) {
387+
$obj->$key = new stdClass();
388+
$this->_array_to_obj($value, $obj->$key);
389+
} else {
390+
$obj->$key = $value;
391+
}
392+
}
393+
return $obj;
394+
}
395+
396+
function arrayToObject($array)
397+
{
398+
$object= new stdClass();
399+
return $this->_array_to_obj($array,$object);
400+
}
401+
402+
382403
/**
383404
* API GET request
384405
*
@@ -390,7 +411,7 @@ private function tokens($data=array()) {
390411
final public function get($path, $data=array()) {
391412
if($data) $path .= '/?' . http_build_query($data);
392413
if($response = $this->api($path)) {
393-
return $response;
414+
return $this->arrayToObject($response);
394415
} else {
395416
return false;
396417
}

0 commit comments

Comments
 (0)