documentation (commiting now from Guadeloupe)

This commit is contained in:
Trismegiste
2013-08-17 19:41:18 -04:00
parent 9a2536bc56
commit 67bdb9fede
3 changed files with 18 additions and 5 deletions

View File

@@ -9,13 +9,14 @@ namespace DesignPatterns\Visitor;
* The Visitor Pattern lets you outsource operations on objects to other objects. The main reason to do this is to keep
* a seperation of concerns. But classes have to define an contract to allow visitors (the "accept" method in the example below).
*
* The contract is an abstract class but you can have also a clean interface
* The contract is an abstract class but you can have also a clean interface.
* In that case, each Visitee has to choose itself which method to invoke on the visitor.
*/
abstract class Role
{
/**
* This method handle a double dispatch based on the shortname of the Visitee
* This method handles a double dispatch based on the shortname of the Visitee
*
* Feel free to override it if your object must call another visiting behavior
*

View File

@@ -5,16 +5,22 @@ namespace DesignPatterns\Visitor;
/**
* Visitor Pattern
*
* An implementation of a Visitor
* An implementation of a concrete Visitor
*/
class RolePrintVisitor implements RoleVisitor
{
/**
* @inheritdoc
*/
public function visitGroup(Group $role)
{
echo "Role: " . $role->getName();
}
/**
* @inheritdoc
*/
public function visitUser(User $role)
{
echo "Role: " . $role->getName();

View File

@@ -5,13 +5,19 @@ namespace DesignPatterns\Visitor;
/**
* Visitor Pattern
*
* The contract for the visitor
* The contract for the visitor.
*
* Note 1 : in C++ or java, with method polymorphism based on type-hint, there are many
* methods visit() with different type for the 'role' parameter.
*
* Note 2 : the visitor must not choose itself which method to
* invoke, it is the Visitee that make this decision.
*/
interface RoleVisitor
{
/**
* Visit a user object
* Visit a User object
*
* @param \DesignPatterns\Visitor\User $role
*/