DEV Community

Discussion on: PHP - Elegant method call

Collapse
 
klauenboesch profile image
Christian

While I understand your case (and I, for sure, have also written such code) I have two main concerns about your example:

  1. You say „a huge class that performs many tasks“. I‘ll just refer to „Single Responsibility Principle“ here: 1 Class -> 1 Purpose/Task

  2. How would you ever write a Unit test for your RefactoredBigClass? There is no way you could ever test your handle() function there.

Thread Thread
 
suddenlyrust profile image
Ruslan

Thank you for your concern, Christian.
At your first point: I don't know what you mean by that 🤔
And to your second point: I'm not unit testing this class 😁

Thread Thread
 
klauenboesch profile image
Christian

For the first point, see: scotch.io/bar-talk/s-o-l-i-d-the-f...
For the second point: Well, that's your fault ;)