10.2. UML

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

Figure 10-1. Figure 10-1

Note the following about this diagram:

MyObject deals with content that needs to be interpreted. It has a private string called content to store the content it needs to work with.

The storeContent() method accepts one parameter, named content. This is the content pre-interpretation. It is then stored internally in the MyObject object.

applyInterpretation() is called next. It creates an instance of MyInterpreter. MyInterpreter has one public method named interpretKeys(). This method accepts the parameter named content. applyInterpretation() and passes its internal content to interpretKeys(). The MyInterpreter class executes the interpretation on the content and then returns it to MyObject. Then applyInterpretation() replaces the internal content variable.

MyObject, finally, provides the content via the getContent() after interpretation.

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.