/** * Gets cached data * * @return $this * @throws DataNotLoadedException */ protected function withCache() { $this->type = 'fromCache'; $data = $this->cache->is_cached($this->label) ? $this->cache->get_cache($this->label) : false; $this->data = $data ? json_decode($data, true) : false; if (!$this->data) { $this->cache->set_cache($this->label, json_encode($this->withoutCache()->get())); } return $this; }