Skip to content

Commit

Permalink
json_decode assoc
Browse files Browse the repository at this point in the history
  • Loading branch information
attogram committed Apr 22, 2020
1 parent 6d7e61f commit 5335de3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use function gmdate;
use function in_array;
use function is_array;
use function json_decode;
use function json_encode;
use function sort;
use function substr;
Expand Down Expand Up @@ -72,13 +73,15 @@ public function get()
*/
private function setDataFromCache()
{
$this->data = json_decode($this->filesystem->get($this->topic));
if (!is_array($this->data)) {
$this->data = $this->filesystem->get($this->topic);
if (!$this->data) {
$this->data = [];

return false;
}

$this->data = json_decode($this->data, true);

return true;
}

Expand Down

0 comments on commit 5335de3

Please sign in to comment.