From 59f28b27889efb1e31985733b72f7838b3f85ac1 Mon Sep 17 00:00:00 2001
From: Tobias Gross-Vogt <tgros@tugraz.at>
Date: Wed, 4 May 2022 09:05:57 +0200
Subject: [PATCH] getCourseById throws instead of returning null

---
 src/API/CourseProviderInterface.php | 14 +++++++++++++-
 src/Service/DummyCourseProvider.php |  2 +-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/API/CourseProviderInterface.php b/src/API/CourseProviderInterface.php
index ee946fc..b08634d 100644
--- a/src/API/CourseProviderInterface.php
+++ b/src/API/CourseProviderInterface.php
@@ -6,28 +6,40 @@ namespace Dbp\Relay\BaseCourseBundle\API;
 
 use Dbp\Relay\BaseCourseBundle\Entity\Course;
 use Dbp\Relay\BaseCourseBundle\Entity\CourseAttendee;
+use Dbp\Relay\CoreBundle\Exception\ApiError;
 
 interface CourseProviderInterface
 {
-    public function getCourseById(string $identifier, array $options = []): ?Course;
+    /**
+     * @throws ApiError
+     */
+    public function getCourseById(string $identifier, array $options = []): Course;
 
     /**
      * @return Course[]
+     *
+     * @throws ApiError
      */
     public function getCourses(array $options = []): array;
 
     /**
      * @return Course[]
+     *
+     * @throws ApiError
      */
     public function getCoursesByOrganization(string $orgUnitId, array $options = []): array;
 
     /**
      * @return Course[]
+     *
+     * @throws ApiError
      */
     public function getCoursesByLecturer(string $lecturerId, array $options = []): array;
 
     /**
      * @return CourseAttendee[]
+     *
+     * @throws ApiError
      */
     public function getAttendeesByCourse(string $courseId, array $options = []): array;
 }
diff --git a/src/Service/DummyCourseProvider.php b/src/Service/DummyCourseProvider.php
index f5683fe..2de0a9d 100644
--- a/src/Service/DummyCourseProvider.php
+++ b/src/Service/DummyCourseProvider.php
@@ -10,7 +10,7 @@ use Dbp\Relay\BaseCourseBundle\Entity\CourseAttendee;
 
 class DummyCourseProvider implements CourseProviderInterface
 {
-    public function getCourseById(string $identifier, array $options = []): ?Course
+    public function getCourseById(string $identifier, array $options = []): Course
     {
         $course = new Course();
         $course->setIdentifier($identifier);
-- 
GitLab