@@ -103,9 +103,34 @@ private function validateAvailability(array $availability): void {
103103 /**
104104 * @throws InvalidArgumentException
105105 */
106- private function validateDurations (int $ length , int $ increment ): void {
107- if ($ length <= 0 || $ increment <= 0 ) {
108- throw new InvalidArgumentException ('Length and increment must be greater than zero ' );
106+ private function validateConfigValues (
107+ int $ length ,
108+ int $ increment ,
109+ int $ preparationDuration ,
110+ int $ followupDuration ,
111+ int $ timeBeforeNextSlot ,
112+ ?int $ dailyMax ,
113+ ?int $ start ,
114+ ?int $ end ,
115+ ?int $ futureLimit ,
116+ ): void {
117+ if ($ length <= 0 ) {
118+ throw new InvalidArgumentException ('Length must be greater than zero ' );
119+ }
120+ if ($ increment < 5 * 60 ) {
121+ throw new InvalidArgumentException ('Increment must be at least 5 minutes ' );
122+ }
123+ if ($ preparationDuration < 0 || $ followupDuration < 0 || $ timeBeforeNextSlot < 0 ) {
124+ throw new InvalidArgumentException ('Durations must not be negative ' );
125+ }
126+ if ($ dailyMax !== null && $ dailyMax <= 0 ) {
127+ throw new InvalidArgumentException ('Daily maximum must be greater than zero ' );
128+ }
129+ if ($ futureLimit !== null && $ futureLimit <= 0 ) {
130+ throw new InvalidArgumentException ('Future limit must be greater than zero ' );
131+ }
132+ if ($ start !== null && $ end !== null && $ start >= $ end ) {
133+ throw new InvalidArgumentException ('Start must be before end ' );
109134 }
110135 }
111136
@@ -154,7 +179,7 @@ public function create(
154179 return JsonResponse::fail ();
155180 }
156181 try {
157- $ this ->validateDurations ($ length , $ increment );
182+ $ this ->validateConfigValues ($ length , $ increment, $ preparationDuration , $ followupDuration , $ timeBeforeNextSlot , $ dailyMax , $ start , $ end , $ futureLimit );
158183 $ this ->validateAvailability ($ availability );
159184 } catch (InvalidArgumentException $ e ) {
160185 return JsonResponse::fail ($ e ->getMessage (), Http::STATUS_UNPROCESSABLE_ENTITY );
@@ -233,7 +258,7 @@ public function update(
233258 return JsonResponse::fail (null , Http::STATUS_NOT_FOUND );
234259 }
235260 try {
236- $ this ->validateDurations ($ length , $ increment );
261+ $ this ->validateConfigValues ($ length , $ increment, $ preparationDuration , $ followupDuration , $ timeBeforeNextSlot , $ dailyMax , $ start , $ end , $ futureLimit );
237262 $ this ->validateAvailability ($ availability );
238263 } catch (InvalidArgumentException $ e ) {
239264 return JsonResponse::fail ($ e ->getMessage (), Http::STATUS_UNPROCESSABLE_ENTITY );
0 commit comments