3.2. UML

This Unified Modified Language (UML) diagram details a class design using the Adapter Design Pattern (see Figure 3-1).

Figure 3-1. Figure 3-1

Note the following about this figure:

  • The MyObject class contains a public method called methodA(). OriginalConsumer acquires an instance of MyObject and calls methodA() during its doSomething() function.

  • The NewConsumer class is introduced. Its doSomething() function expects to call a public method of the MyObject instance called methodB() during execution.

  • The MyObjectAdapterForNewConsumer is created by extending the MyObject class. It then provides a public method called methodB() as expected by NewConsumer. In this simple example, all methodB() does is call methodA().

Get Professional PHP Design Patterns 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.