Time and again, I have spoken about API integrations, and each time I find an improvement from the last, once more into the fray. This stood out as it somewhat mirrored how I do API integrations and inspired me to add my own two cents.
I feel like I can expand upon it a little with my lessons learned in API development and integrations.
/** * @mixin ResourceContract */ trait CanAccessClient { public function __construct( private readonly ClientContract $client, ) {} public function client(): ClientContract { return $this->client; }}
final class Client implements ClientContract { use SendsRequests; public function __construct( private readonly PendingRequest $request, ) {} public function issues(): IssuesResource { return new IssuesResource( client: $this, ); }}