Chapter 5. MOD UR CLASS

Chapter 4 left us with some clear objectives. We need to add functionality to the DirectoryItems class, and we need to upgrade it to take advantage of the changes introduced in PHP 5. And that's exactly what we'll do in this chapter. We'll upgrade the syntax of the DirectoryItems class first; then we'll improve its functionality by adding methods.

Keeping in mind that we plan to use the DirectoryItems class to display images, we'll add a method that ignores all non-image files, so we don't need to worry if other file types occur within a directory containing mostly images. We'll also broaden the scope of the class so that we can filter the contents of a directory and focus on a specific file type.

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.