Skip to content

Commit

Permalink
These may possibly return null so don't assign to not nullable param
Browse files Browse the repository at this point in the history
  • Loading branch information
spaze committed May 14, 2022
1 parent a5c5e24 commit 2b6ace4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions site/app/Admin/Presenters/TrainingsPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,18 @@ public function __construct(
}


/**
* @throws BadRequestException
*/
public function actionDate(int $param): void
{
$this->dateId = $param;
$this->redirectParam = $this->dateId;
$this->training = $this->trainingDates->get($this->dateId);
if (!$this->training) {
$training = $this->trainingDates->get($this->dateId);
if (!$training) {
throw new BadRequestException("Date id {$param} does not exist, yet");
}
$this->training = $training;
$validCount = 0;
$applications = $discarded = [];
foreach ($this->trainingApplications->getByDate($this->dateId) as $application) {
Expand Down Expand Up @@ -151,13 +155,17 @@ public function actionReview(int $param): void
}


/**
* @throws BadRequestException
*/
public function actionApplication(int $param): void
{
$this->applicationId = $param;
$this->application = $this->trainingApplications->getApplicationById($this->applicationId);
if (!$this->application) {
$application = $this->trainingApplications->getApplicationById($this->applicationId);
if (!$application) {
throw new BadRequestException("No application with id {$this->applicationId}");
}
$this->application = $application;

if (isset($this->application->dateId)) {
$this->dateId = $this->application->dateId;
Expand Down

0 comments on commit 2b6ace4

Please sign in to comment.