mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-24 17:52:25 +01:00
33 lines
482 B
PHP
33 lines
482 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Behavioral\Visitor;
|
|
|
|
/**
|
|
* Visitor Pattern
|
|
*
|
|
* One example for a visitee. Each visitee has to extends Role
|
|
*/
|
|
class User extends Role
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $name;
|
|
|
|
/**
|
|
* @param string $name
|
|
*/
|
|
public function __construct($name)
|
|
{
|
|
$this->name = (string) $name;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getName()
|
|
{
|
|
return "User " . $this->name;
|
|
}
|
|
}
|