mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-09-25 13:59:08 +02:00
29 lines
681 B
PHP
29 lines
681 B
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace DesignPatterns\Behavioral\Mediator;
|
|
|
|
class UserRepositoryUiMediator implements Mediator
|
|
{
|
|
private UserRepository $userRepository;
|
|
private Ui $ui;
|
|
|
|
public function __construct(UserRepository $userRepository, Ui $ui)
|
|
{
|
|
$this->userRepository = $userRepository;
|
|
$this->ui = $ui;
|
|
|
|
$this->userRepository->setMediator($this);
|
|
$this->ui->setMediator($this);
|
|
}
|
|
|
|
public function printInfoAbout(string $user)
|
|
{
|
|
$this->ui->outputUserInfo($user);
|
|
}
|
|
|
|
public function getUser(string $username): string
|
|
{
|
|
return $this->userRepository->getUserName($username);
|
|
}
|
|
}
|