But Will It Fly?

OO enthusiasts are usually eager to point out the big ways in which OOP is superior to procedural programming, through capabilities such as inheritance, for instance. True enough, but probably of more importance is the fact that once you have a class, providing that the basic design is sound, you can easily add to its functionality. If it doesn't do something you want it to do, the simplest and often the best solution is to add a method to create additional behavior.

For example, you could easily add a method modeled on the method checkAllImages that would check for other types of files. Or, suppose some of the files in the directory passed to the constructor are not image files, and you don't want your program to attempt to ...

Get Object-Oriented PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.