Skip to content

Commit

Permalink
Fix static analysis.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Nov 29, 2023
1 parent ba0325f commit b992bf9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/UseCase/Contact/ContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function actions(): array
[
'index' => [
'class' => Index\IndexAction::class,
'formModelClass' => $this->formModelClass,
],
'captcha' => [
'class' => CaptchaAction::class,
Expand Down
12 changes: 9 additions & 3 deletions src/UseCase/Contact/Index/IndexAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
namespace App\UseCase\Contact\Index;

use App\UseCase\Contact\ContactEvent;
use App\UseCase\Contact\ContactForm;
use yii\base\Action;
use yii\base\InvalidConfigException;
use yii\symfonymailer\Mailer;
use yii\web\Controller;
use yii\web\Request;
Expand All @@ -14,6 +16,8 @@

final class IndexAction extends Action
{
public string $formModelClass = '';

public function __construct(
string $id,
Controller $controller,
Expand All @@ -26,7 +30,11 @@ public function __construct(

public function run(): Response|string
{
$contactForm = new $this->controller->formModelClass();
if ($this->formModelClass === '') {
throw new InvalidConfigException('The "formModelClass" property must be set.');

Check warning on line 34 in src/UseCase/Contact/Index/IndexAction.php

View check run for this annotation

Codecov / codecov/patch

src/UseCase/Contact/Index/IndexAction.php#L34

Added line #L34 was not covered by tests
}

$contactForm = new $this->formModelClass();
$contactEvent = new ContactEvent();

if (
Expand All @@ -39,8 +47,6 @@ public function run(): Response|string

$this->trigger(ContactEvent::EVENT_AFTER_SEND, $contactEvent);
}

return $this->controller->refresh();
}

return $this->controller->render(
Expand Down

0 comments on commit b992bf9

Please sign in to comment.