Level 67
Personally I think it's abstraction to the point of absurdity. I'd much rather have a single repository that has the responsibility of managing the data for an entity than 50 or 60 individual classes. I really don't see the benefit.
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm sure I've heard JW mention the idea in one of his videos (or I might have dreamed it). But the thought of distilling repositories down and SRP occurred to me today while I was mucking about with a toy project.
I'd be interested in people's opinions of single query classes and the ups and downs of using them.
Something like this ...
class PropertyRatesInRange
{
public static function get(int $propertyId, DateRange $range) : Collection
{
$property = Property::with('rates')->find($propertyId);
return $property->rates->filter(function($rates) use($range) {
return $rates->dates->overlaps($range);
});
}
}
Please or to participate in this conversation.