Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/MessageName.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,23 @@
final readonly class MessageName
{
/**
* @var non-empty-string
* @param non-empty-string $name
*/
private string $name;
private function __construct(private string $name) {}

/**
* @throws InvalidMessageName If the message name is empty.
*
* @phpstan-assert non-empty-string $name
*/
private function __construct(string $name)
public static function fromString(string $name): self
{
if (\trim($name) === '') {
throw InvalidMessageName::empty();
}

/** @var non-empty-string $name */
$this->name = $name;
}

/**
* @throws InvalidMessageName If the message name is empty.
*/
public static function fromString(string $name): self
{
return new self($name);
}

Expand Down