mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-23 17:22:41 +01:00
28 lines
454 B
PHP
28 lines
454 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Behavioral\Visitor;
|
|
|
|
/**
|
|
* Visitor Pattern
|
|
*
|
|
* An implementation of a concrete Visitor
|
|
*/
|
|
class RolePrintVisitor implements RoleVisitorInterface
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function visitGroup(Group $role)
|
|
{
|
|
echo "Role: " . $role->getName();
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function visitUser(User $role)
|
|
{
|
|
echo "Role: " . $role->getName();
|
|
}
|
|
}
|