Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/getjump/Vk/Response/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ class Api
*/
public function __construct($data, $callback = false)
{
$this->response = !isset($data->response) ? false : new Response($data->response, $callback);
if (!isset($data->response)) {
$this->response = false;
} else {
if (!is_object($data->response) && !is_array($data->response)) {
$this->response = new Response($data, $callback);
} else {
$this->response = new Response($data->response, $callback);
}
}
$this->error = !isset($data->error) ? false : new Error($data->error);
}

Expand Down
2 changes: 1 addition & 1 deletion src/getjump/Vk/Response/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct($data, $callback = false)
}
$this->count = !isset($data->count) ? false : $data->count;
if (is_array($data) || !isset($data->items)) {
$this->count = count($data);
$this->count = count((array) $data);
if (is_array($data) && is_callable($callback)) {
foreach ($data as $d) {
$this->data[] = call_user_func_array($callback, [$d]);
Expand Down