Skip to content

Commit 67bdb9f

Browse files
committed
documentation (commiting now from Guadeloupe)
1 parent 9a2536b commit 67bdb9f

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

Visitor/Role.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
* The Visitor Pattern lets you outsource operations on objects to other objects. The main reason to do this is to keep
1010
* a seperation of concerns. But classes have to define an contract to allow visitors (the "accept" method in the example below).
1111
*
12-
* The contract is an abstract class but you can have also a clean interface
12+
* The contract is an abstract class but you can have also a clean interface.
13+
* In that case, each Visitee has to choose itself which method to invoke on the visitor.
1314
*/
1415
abstract class Role
1516
{
1617

1718
/**
18-
* This method handle a double dispatch based on the shortname of the Visitee
19+
* This method handles a double dispatch based on the shortname of the Visitee
1920
*
2021
* Feel free to override it if your object must call another visiting behavior
2122
*

Visitor/RolePrintVisitor.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@
55
/**
66
* Visitor Pattern
77
*
8-
* An implementation of a Visitor
8+
* An implementation of a concrete Visitor
99
*/
1010
class RolePrintVisitor implements RoleVisitor
1111
{
1212

13+
/**
14+
* @inheritdoc
15+
*/
1316
public function visitGroup(Group $role)
1417
{
1518
echo "Role: " . $role->getName();
1619
}
1720

21+
/**
22+
* @inheritdoc
23+
*/
1824
public function visitUser(User $role)
1925
{
2026
echo "Role: " . $role->getName();

Visitor/RoleVisitor.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@
55
/**
66
* Visitor Pattern
77
*
8-
* The contract for the visitor
8+
* The contract for the visitor.
9+
*
10+
* Note 1 : in C++ or java, with method polymorphism based on type-hint, there are many
11+
* methods visit() with different type for the 'role' parameter.
12+
*
13+
* Note 2 : the visitor must not choose itself which method to
14+
* invoke, it is the Visitee that make this decision.
915
*/
1016
interface RoleVisitor
1117
{
1218

1319
/**
14-
* Visit a user object
20+
* Visit a User object
1521
*
1622
* @param \DesignPatterns\Visitor\User $role
1723
*/

0 commit comments

Comments
 (0)