Builds and returns the Message object.
Source
public function get(): Message
{
if (empty($this->parts)) {
throw new InvalidArgumentException('Cannot build an empty message. Add content using withText() or similar methods.');
}
if ($this->role === null) {
throw new InvalidArgumentException('Cannot build a message with no role. Set a role using usingRole() or similar methods.');
}
// At this point, we've validated that $this->role is not null
/** @var MessageRoleEnum $role */
$role = $this->role;
return new Message($role, $this->parts);
}
Changelog
| Version | Description |
|---|---|
| 0.2.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.