O'Reilly logo

Professional PHP Design Patterns by Aaron Saray

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

23.1. Working with Contacts Import

Even though the specifications said that only one type of import would be specified, I've decided to be more safe than sorry. Currently, the requirement is to accept contact imports from the official company address book in the Microsoft Outlook program. However, after some of the employees see the ease with which this tool can be used, I am predicting that a need for other unofficial address book migrations will arise. As much as the company has tried to make a piece of software the official supported tool, there will always be users using other pieces of software (especially us in IT).

There are two parts to this process that remain tightly coupled. The first is the Adapter object that manipulates the Contact name information. The other is the object that builds an array of items to traverse from the file's contents. I'll look at each of these individually next.

23.1.1. Outlook Contact Adapter

Right now, the import is being accepted as a .csv file that was exported from Outlook. I don't want to confuse the users of the software by giving them too many options that aren't available, however. I am going to modify the processing portions of the code to be more flexible, using some Design Patterns. The view for the import will look relatively the same.

I've created the following UML diagram (Figure 23-1):

Figure 23-1. Figure 23-1

The importadapter ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required