refactor: harden error handeling

This commit is contained in:
HDVinnie
2020-12-02 21:24:03 -05:00
parent 99c11a89e8
commit b65d327aac
14 changed files with 16 additions and 16 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ class EmailBlacklistUpdater
$key = \config('email-blacklist.cache-key');
$duration = Carbon::now()->addMonth();
$domains = \json_decode(\file_get_contents($url), true);
$domains = \json_decode(\file_get_contents($url), true, 512, JSON_THROW_ON_ERROR);
$count = \is_countable($domains) ? \count($domains) : 0;
// Retrieve blacklisted domains
@@ -39,7 +39,7 @@ class VersionController extends Controller
public function checkVersion()
{
$client = new Client();
$response = \json_decode($client->get('//api.github.com/repos/HDInnovations/UNIT3D/releases')->getBody());
$response = \json_decode($client->get('//api.github.com/repos/HDInnovations/UNIT3D/releases')->getBody(), true);
$lastestVersion = $response[0]->tag_name;
return \response([
+1 -1
View File
@@ -39,7 +39,7 @@ class Collection
$response = $this->client->request('get', 'https://api.TheMovieDB.org/3/collection/'.$id);
$this->data = json_decode($response->getBody()->getContents(), true);
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
}
public function index()
+2 -2
View File
@@ -40,7 +40,7 @@ class Company
$response = $this->client->request('get', 'https://api.TheMovieDB.org/3/company/'.$id);
$this->data = json_decode($response->getBody()->getContents(), true);
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
}
public function index()
@@ -118,7 +118,7 @@ class Company
$array = [];
$this->page = 1;
while ($data = $this->data['movies'][$this->page++]) {
$json = json_decode($data, true); //01
$json = json_decode($data, true, 512, JSON_THROW_ON_ERROR); //01
foreach ($json['results'] as $row) {
$array[] = $row;
}
+1 -1
View File
@@ -39,7 +39,7 @@ class Episode
$response = $this->client->request('get', 'https://api.TheMovieDB.org/3/tv/'.$id.'/season/'.$season.'/episode/'.$episode);
$this->data = json_decode($response->getBody()->getContents(), true);
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
}
public function index()
+1 -1
View File
@@ -38,7 +38,7 @@ class FindMovie
$response = $this->client->request('get', 'https://api.themoviedb.org/3/search/movie?api_key='.config('api-keys.tmdb').'&query='.$query.'&first_air_date_year='.$year);
$this->data = json_decode($response->getBody()->getContents(), true);
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
}
public function index()
+1 -1
View File
@@ -38,7 +38,7 @@ class FindTv
$response = $this->client->request('get', 'https://api.themoviedb.org/3/search/tv?api_key='.config('api-keys.tmdb').'&query='.$query.'&first_air_date_year='.$year);
$this->data = json_decode($response->getBody()->getContents(), true);
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
}
public function index()
+1 -1
View File
@@ -38,7 +38,7 @@ class Genre
$response = $this->client->request('get', 'https://api.TheMovieDB.org/3/genre/'.$id);
$this->data = json_decode($response->getBody()->getContents(), true);
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
}
public function index()
+1 -1
View File
@@ -39,7 +39,7 @@ class Movie
$response = $this->client->request('get', 'https://api.themoviedb.org/3/movie/'.$id);
$this->data = json_decode($response->getBody()->getContents(), true);
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
}
public function index()
+1 -1
View File
@@ -39,7 +39,7 @@ class Network
$response = $this->client->request('get', 'https://api.TheMovieDB.org/3/network/'.$id);
$this->data = json_decode($response->getBody()->getContents(), true);
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
}
public function index()
+1 -1
View File
@@ -39,7 +39,7 @@ class Person
$response = $this->client->request('get', 'https://api.TheMovieDB.org/3/person/'.$id);
$this->data = json_decode($response->getBody()->getContents(), true);
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
}
public function index()
+1 -1
View File
@@ -39,7 +39,7 @@ class Season
$response = $this->client->request('get', 'https://api.TheMovieDB.org/3/tv/'.$id.'/season/'.$season);
$this->data = json_decode($response->getBody()->getContents(), true);
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
}
public function index()
+1 -1
View File
@@ -39,7 +39,7 @@ class TV
$response = $this->client->request('get', 'https://api.TheMovieDB.org/3/tv/'.$id);
$this->data = json_decode($response->getBody()->getContents(), true);
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
}
public function index()
+2 -2
View File
@@ -123,7 +123,7 @@ trait Auditable
$clean = \array_filter($data);
return \json_encode($clean);
return \json_encode($clean, JSON_THROW_ON_ERROR);
}
/**
@@ -181,7 +181,7 @@ trait Auditable
// Generate the JSON to store
$data = self::generate('update', self::strip($model, $model->getOriginal()), self::strip($model, $model->getChanges()));
if (! \is_null($userId) && ! empty(\json_decode($data, true))) {
if (! \is_null($userId) && ! empty(\json_decode($data, true, 512, JSON_THROW_ON_ERROR))) {
// Store record
$now = Carbon::now()->format('Y-m-d H:i:s');
DB::table('audits')->insert([