19.2. UML

This Unified Modified Language (UML) diagram details a class design using the Visitor Design Pattern (see Figure 19-1). Note the following about this diagram:

  • The MyObject class can be visited. It is the base class. It has one public method called acceptVisitor(). This method accepts a parameter called Visitor. Internally, the acceptVisitor() class calls the public method visit() from the Visitor parameter object that it is passed. It passes in an instance of itself.

  • The MyVisitor class is the Visitor in this diagram. All Visitors are required to have the public method visit(). This method accepts an instance of MyObject. The visit() method may call additional logic, such as the protected doSomething() method. This is the unique portion of the visiting class.

Figure 19-1. Figure 19-1

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.