I have a number of classes with a single public method. Looking at this answer, I tend to agree with what is stated.
The OP lists some examples, which I interpret to be used like
(new VideoCompressor)->compress($raw_video);
While the readability improves slightly by calling the explicit method name, I feel it is almost as readable by simply moving the parameters to a __construct()
and calling the compress
function from within the constructor.
new VideoCompressor($raw_video);
This however would add a constructor to the class if it didn't have one already.
In my eyes it would be a trade between slightly smaller calls to classes in exchange for more code within the class.
Is there any other reason either method should be preferred other than personal taste?