Liskov Substitution SubClass should be replaceable with base class without any behavior breaks. To fix above code, we can do something like this Coding to interface will be how to follow liskuv principle, always make sure that all functions in classes implements same interface will return same type; else you will find yourself violating liskuve […]
Open-Closed Principle (OCP) Open for extension closed for modification. To fix above code, we can do something like this Now when we have change-request in requirements to add paypal method, all we have to do is adding another paypal class implements same PaymentInterface and thats it, so we extended(open for extension) our application with paypal […]
Single Responsibility Principle (SRP) A class or function should have one and only one reason to change To fix above code, we can do something like this Now you have 2 classes each one has one responsibility, with Laravel you can apply “Single Action Controller” method to make sure each class has only one responsibility.