Laravel is an implementation of the Model-View-Controller design pattern. The MVC design pattern does not include the idea of a "service class". Business logic and data access is crammed into the "Model" part of MVC. This part of the design pattern is loosely defined. The most important thing to remember with MVC is that it is a user ...
Injecting a class isn't really a violation of the Single Responsibility Principle.
The new logic is encapsulated in your Operation class, that's it's responsibility. Calling a dependency doesn't really change what this class responsibile for.
Something like the below isn't really changing the responsibilities of your DAO class.
(forgive the C# syntax)
You don’t modify class User when a new Request subclass is created. You modify class User when there is a new business requirement, and that’s when you both can and must modify it.
Is there a reason why the request that seems to be needed has to be implemented as a subclass of RequestB? I’d define an interface for it, so you can call methods of that request ...
Prefer polymorphism to downcasts.
User is violating the Request abstraction by knowing which request it's talking to.
Now that doesn't mean Foo and Boo must use the same Request instance:
public class User
public Request FooRequest;
public Request BooRequest;
// Foo calls Request methods on a FooRequest instance
public void Foo();
Having a single responsibility does not mean "to do one thing". It means "to be one thing".
You want your printer class to be a printer only and not also an alarm clock and toaster just because it can make some noise and generate heat (how convenient).
SRP is about identity, ISP is about behaviors.
Indeed in many environments you too ...
Splitting the interface does not necessarily mean that you should split the class. You can think of interfaces as of a roles an object of a class is playing in the context of some client code. An object can play more than one role - e.g. picture two different clients "seeing" two different aspects of the same concept. The aspects themselves could ...