Refactor Classes
This commit is contained in:
@@ -21,9 +21,9 @@ class WorkingHoursController extends AbstractController
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Response $response
|
||||
* @param mixed[] $args
|
||||
* @param Request $request
|
||||
* @param Response $response
|
||||
* @param array<string, mixed> $args
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
@@ -44,9 +44,9 @@ class WorkingHoursController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Response $response
|
||||
* @param mixed[] $args
|
||||
* @param Request $request
|
||||
* @param Response $response
|
||||
* @param array<string, mixed> $args
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
@@ -59,21 +59,29 @@ class WorkingHoursController extends AbstractController
|
||||
$repository = new WorkingHoursRepository($this->databases);
|
||||
$queryParams = $request->getQueryParams();
|
||||
try {
|
||||
return $this->printResponse($response, $repository->findFiltered(
|
||||
$queryParams['start-date'] ?? null,
|
||||
$queryParams['end-date'] ?? null
|
||||
), StatusCodeInterface::STATUS_OK);
|
||||
return $this->printResponse(
|
||||
$response,
|
||||
$repository->findFiltered(
|
||||
$queryParams['start-date'] ?? null,
|
||||
$queryParams['end-date'] ?? null
|
||||
),
|
||||
StatusCodeInterface::STATUS_OK
|
||||
);
|
||||
} catch (RepositoryBadWhereDataException $exception) {
|
||||
throw new HttpBadRequestException($request, 'Ein Wert für das Datum im Query ist ungültig', $exception);
|
||||
} catch (Exception $exception) {
|
||||
throw new HttpInternalServerErrorException($request, 'Der Wert für das Datum oder die Zeit ist falsch in der Datenbank', $exception);
|
||||
throw new HttpInternalServerErrorException(
|
||||
$request,
|
||||
'Der Wert für das Datum oder die Zeit ist falsch in der Datenbank',
|
||||
$exception
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Response $response
|
||||
* @param mixed[] $args
|
||||
* @param Request $request
|
||||
* @param Response $response
|
||||
* @param array<string, mixed> $args
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
@@ -88,14 +96,18 @@ class WorkingHoursController extends AbstractController
|
||||
} catch (RepositoryRecordNotFoundException $exception) {
|
||||
throw new HttpNotFoundException($request, 'Der Eintrag ist nicht vorhanden.', $exception);
|
||||
} catch (Exception $exception) {
|
||||
throw new HttpInternalServerErrorException($request, 'Der Wert für das Datum oder die Zeit ist falsch in der Datenbank', $exception);
|
||||
throw new HttpInternalServerErrorException(
|
||||
$request,
|
||||
'Der Wert für das Datum oder die Zeit ist falsch in der Datenbank',
|
||||
$exception
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Response $response
|
||||
* @param mixed[] $args
|
||||
* @param Request $request
|
||||
* @param Response $response
|
||||
* @param array<string, mixed> $args
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
@@ -114,7 +126,11 @@ class WorkingHoursController extends AbstractController
|
||||
} catch (RepositoryRecordAlreadyExistException $exception) {
|
||||
throw new HttpConflictRequestException($request, 'Der Eintrag ist schon vorhanden.', $exception);
|
||||
} catch (Exception $exception) {
|
||||
throw new HttpInternalServerErrorException($request, 'Der Wert für das Datum oder die Zeit ist falsch in der Datenbank', $exception);
|
||||
throw new HttpInternalServerErrorException(
|
||||
$request,
|
||||
'Der Wert für das Datum oder die Zeit ist falsch in der Datenbank',
|
||||
$exception
|
||||
);
|
||||
}
|
||||
return $this->printResponse($response, $model, StatusCodeInterface::STATUS_CREATED);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user