Lately, I’ve written extensively about object-oriented PHP, from class inheritance and visibility, to design patterns and magic methods. In all of these discussions, I’ve talked about classes without taking into account object interfaces. Interfaces, often referred to as contracts or agreements, set up rules for classes in which a class that implements an interface has to follow those specific rules. Interfaces put constraints on your classes that improve your code. In this article, I’m going to discuss what interfaces are and what they can and can’t do. By the end, you will be able to see if you should use interfaces to improve your code. […]
No Comments