Skip to content

Commit

Permalink
Make php artisan send-test-mail option --from optional
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Apr 2, 2024
1 parent 7bd7d4f commit 69b8a33
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ See [GitHub releases](https://github.com/mll-lab/laravel-utils/releases).

## Unreleased

## v4.12.0

### Changed

- Make `php artisan send-test-mail` option `--from` optional

## v4.11.0

### Added
Expand Down
10 changes: 6 additions & 4 deletions src/Mail/SendTestMailCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ public function handle(): void
$mail = new TestMail();

$from = $this->option('from');
if (! is_string($from)) {
$fromType = gettype($from);
throw new \UnexpectedValueException("Expected option --from to be string, got {$fromType}.");
if (! is_null($from)) {
if (! is_string($from)) { // @phpstan-ignore-line option values can also be arrays
$fromType = gettype($from);
throw new \UnexpectedValueException("Expected option --from to be string, got {$fromType}.");
}
$mail->from($from);
}
$mail->from($from);

$to = $this->option('to');
if (! is_string($to)) {
Expand Down

0 comments on commit 69b8a33

Please sign in to comment.