<?php namespace App\Fetching; use App\Utils\Debug; class ApiFeed { public $json; /** * Loads JSON data from a URL and decodes it. * * @param string $url The URL to load JSON data from. * @return object The object instance. */ public function load(string $url): object { try { $client = new \GuzzleHttp\Client(); $response = $client->request('GET', $url); $this->json = json_decode($response->getBody(), true); return $this; } catch (\Exception $e) { echo 'Catch in : ', $e->getMessage(), "\n"; } } }