Skip to content

Commit 1ff2f61

Browse files
add generic types for dto and dtoOrFail
1 parent e669e85 commit 1ff2f61

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Http/Response.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,12 @@ public function collect(string|int|null $key = null): Collection
287287

288288
/**
289289
* Cast the response to a DTO.
290+
*
291+
* @template T of object
292+
* @param class-string<T>|null $dto
293+
* @return T
290294
*/
291-
public function dto(): mixed
295+
public function dto(?string $dto = null): mixed
292296
{
293297
$request = $this->pendingRequest->getRequest();
294298
$connector = $this->pendingRequest->getConnector();
@@ -304,8 +308,12 @@ public function dto(): mixed
304308

305309
/**
306310
* Convert the response into a DTO or throw a LogicException if the response failed
311+
*
312+
* @template T of object
313+
* @param class-string<T>|null $dto
314+
* @return T
307315
*/
308-
public function dtoOrFail(): mixed
316+
public function dtoOrFail(?string $dto = null): mixed
309317
{
310318
if ($this->failed()) {
311319
throw new LogicException('Unable to create data transfer object as the response has failed.', 0, $this->toException());

0 commit comments

Comments
 (0)