diff --git a/app/Data/ItemsCollection.php b/app/Data/ItemsCollection.php index f7a5894..03f962d 100644 --- a/app/Data/ItemsCollection.php +++ b/app/Data/ItemsCollection.php @@ -2,6 +2,7 @@ namespace App\Data; +use App\Exceptions\ItemNotFoundException; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Str; @@ -43,9 +44,10 @@ class ItemsCollection /** * @param string $id * @return array + * @throws ItemNotFoundException */ - public function getItemById(string $id) + public function getItemById(string $id): array { - return $this->data[$id]; + return $this->data[$id] ?? throw new ItemNotFoundException('Item not found'); } }