Skip to content

Commit 3bc7064

Browse files
committed
refactor: simplifies MessagePart::fromArray
1 parent 1f77a32 commit 3bc7064

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/Messages/DTO/MessagePart.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,13 @@ public static function fromArray(array $array): MessagePart
267267
}
268268
$functionCallData = $array['functionCall'];
269269
return new self(FunctionCall::fromArray($functionCallData));
270-
} elseif ($type->isFunctionResponse()) {
270+
} else {
271+
// Function response is the only remaining option
271272
if (!isset($array['functionResponse'])) {
272273
throw new \InvalidArgumentException('Function response message part requires functionResponse field.');
273274
}
274275
$functionResponseData = $array['functionResponse'];
275276
return new self(FunctionResponse::fromArray($functionResponseData));
276277
}
277-
278-
throw new \InvalidArgumentException(sprintf('Unknown message part type: %s', $array['type']));
279278
}
280279
}

0 commit comments

Comments
 (0)