Skip to content

Commit 95d01b7

Browse files
committed
Throw an InvalidArgumentException when missing the array key
Enforces the new state. Consider adding a BadConfigurationException?
1 parent 26be37d commit 95d01b7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/framework/src/Foundation/Concerns/HasKernelData.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Hyde\Foundation\Concerns;
66

77
use Hyde\Facades\Config;
8+
use InvalidArgumentException;
89
use Illuminate\Support\Collection;
910
use Hyde\Framework\Features\Blogging\Models\PostAuthor;
1011

@@ -50,6 +51,10 @@ public function authors(): Collection
5051
protected function parseConfigurationAuthors(Collection $authors): Collection
5152
{
5253
return $authors->mapWithKeys(function (PostAuthor $author, string $username): array {
54+
if (! $username) {
55+
throw new InvalidArgumentException('Author username cannot be empty. Did you forget to set the author\'s array key?');
56+
}
57+
5358
return [$username => tap($author, fn (PostAuthor $author) => $author->username = $username)];
5459
});
5560
}

0 commit comments

Comments
 (0)