mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-10 00:46:38 +02:00
reworked the Mediator pattern
This commit is contained in:
35
Behavioral/Mediator/UserRepositoryUiMediator.php
Normal file
35
Behavioral/Mediator/UserRepositoryUiMediator.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace DesignPatterns\Behavioral\Mediator;
|
||||
|
||||
class UserRepositoryUiMediator implements Mediator
|
||||
{
|
||||
/**
|
||||
* @var UserRepository
|
||||
*/
|
||||
private $userRepository;
|
||||
|
||||
/**
|
||||
* @var Ui
|
||||
*/
|
||||
private $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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user