A class with a single meaningful method usually ends up named after the verb — PriceFormatter::format() — and read as a stutter at every call site. __invoke() lets the object be called directly, which makes it interchangeable with a closure everywhere a callable is expected.
final class PriceFormatter
{
public function __invoke(Money $amount)
{
return number_format($amount->cents() / 100, 2);
}
}
$format = new PriceFormatter();
echo $format($total);
$labels = array_map($format, $amounts);
The advantage over a closure is that the object can take constructor dependencies — a locale, a currency — while still passing to array_map() or usort() as a plain callable. Use it when there genuinely is one operation; a class with __invoke() and four other public methods is just confusing.