When designing Loops federation, I came up with a system of Validators, Handlers and Builders for each type of activity.
I borrowed this from my WIP Laravel ActivityPub library, and it leverages a simple activityMap to handle incoming activities by first validating them, then handling them in a clean and clear way
I will be abstracting this to the Laravel ActivityPub library to make it easier for laravel devs to add ActivityPub support, and will be using it in Pixelfed
https://github.com/joinloops/loops-server/blob/main/app/Services/ActivityService.php#L71