packagist saloonphp/saloon v0.8.1
Version v0.8.1

latest releases: v3.x-dev, v3.10.0, v3.9.1...
2 years ago

This release introduces a first-party way to cast directly to a DTO of your choice.

Firstly, add the "CastsToDto" trait to your request. After that, you need to add the "castToDto" method on the request. This should return your DTO with the data populated inside of it.

public function castToDto(SaloonResponse $response): object
{
    return User::fromSaloon($response);
}

After your request has been sent, you can use the dto method on the response to retrieve your DTO.

$response = UserRequest::make()->send();
$dto = $response->dto(); // Data\User

What's Changed

Full Changelog: v0.8.0...v0.8.1

Don't miss a new saloon release

NewReleases is sending notifications on new releases.