r/PHPhelp • u/Ok-Fisherman7532 • Jan 21 '25
How decouple method from request?
How can I decouple a method from a request? I’d like to pass a generic object (e.g., a DTO) instead of being tied to a request. This way, I could call that specific method both from an API and from a command. What would be the best approach to achieve this? Thank you
1
Upvotes
View all comments
Show parent comment
1
u/equilni Jan 22 '25
The error tells you what the issue is. You didn't build the SignatureRequestData object, as
createSignatureRequestrequests.SignatureRequestData::constructor doesn't make sense. How do you know if you passed an array or the Request object??? Use a Data Transfer Object: