mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-28 02:30:20 +02:00
27 lines
432 B
PHP
27 lines
432 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Behavioral\Visitor;
|
|
|
|
class User implements Role
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
private $name;
|
|
|
|
public function __construct(string $name)
|
|
{
|
|
$this->name = $name;
|
|
}
|
|
|
|
public function getName(): string
|
|
{
|
|
return sprintf('User %s', $this->name);
|
|
}
|
|
|
|
public function accept(RoleVisitorInterface $visitor)
|
|
{
|
|
$visitor->visitUser($this);
|
|
}
|
|
}
|