From 59e6ae1ce14691f8d03ec04154901244f4668d1f Mon Sep 17 00:00:00 2001 From: Niels Vanpachtenbeke <10651054+Nielsvanpach@users.noreply.github.com> Date: Thu, 25 Jan 2024 12:16:27 +0100 Subject: [PATCH] fix warning in case a file is not found --- src/Concerns/Translatable.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Concerns/Translatable.php b/src/Concerns/Translatable.php index 0c65b5f7a..237c8905a 100644 --- a/src/Concerns/Translatable.php +++ b/src/Concerns/Translatable.php @@ -13,8 +13,13 @@ protected function translate(string $country, string $name, ?string $locale = nu } $countryName = strtolower($country); + $filePath = __DIR__."/../../lang/{$countryName}/{$locale}/holidays.json"; - $content = file_get_contents(__DIR__."/../../lang/{$countryName}/{$locale}/holidays.json"); + if (file_exists($filePath)) { + $content = file_get_contents($filePath); + } else { + throw InvalidLocale::notFound($country, $locale); + } if ($content === false) { throw InvalidLocale::notFound($country, $locale);