Skip to content

Commit

Permalink
1.0.4
Browse files Browse the repository at this point in the history
* [+] Release
* [+] `getPageFullExport()` can return array or stdClass
  • Loading branch information
KarelWintersky committed Aug 4, 2022
1 parent ef51db8 commit 96e2507
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions interfaces/LongreadsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ public function fetchPagesList(): array;
* Возвращает Json-decoded информацию о лонгриде
*
* @param $id
* @return stdClass
* @param null $associative (null|true)
* @return stdClass|array
*/
public function getPageFullExport($id):stdClass;
public function getPageFullExport($id, $associative = null);
}

# -eof-
6 changes: 3 additions & 3 deletions sources/Longreads.php
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ public function fetchPagesList():array
return $pages_list;
}

public function getPageFullExport($id):stdClass
public function getPageFullExport($id, $associative = null)
{
$http_request_query = [
'publickey' => $this->api_options['public_key'],
Expand All @@ -641,7 +641,7 @@ public function getPageFullExport($id):stdClass
throw new RuntimeException( "[getPageFullExport] ERROR: Не удалось получить данные с Tilda API" );
}

$response = json_decode($response);
$response = json_decode($response, $associative);

if (false === $response) {
throw new RuntimeException( "[getPageFullExport] ERROR: Не удалось json-декодировать данные с Tilda API" );
Expand All @@ -652,7 +652,7 @@ public function getPageFullExport($id):stdClass
} catch (RuntimeException $e) {
$this->logger->debug($e->getMessage(), [ $e->getCode(), $url ]);

return new stdClass();
return $associative ? [] : new stdClass();
}
}

Expand Down

0 comments on commit 96e2507

Please sign in to comment.