# 2V Modules - code review task ## Что не так Класс DecoratorManager берет на себя слишком много задач, соединение бд, сеттер лог, в коде нет использования setLogger. Имя метод getResponse внутри добавление данных, getCacheKey тоже самое. По названию файла не понятно для чего данный классы, например DataProvider и DecoratorManager Сам код не проверял, просто раскидал как будет лучше :] ```php= <?php namespace src\Integration; class DatabaseConfiguration extends DatabaseConnectionInterface { /** * @param $host * @param $user * @param $password */ public function __construct( public string $host, public string $user, public string $password) {} public function setHost(string $host): void { $this->host = $host; } public function getHost(): string { return $this->host; } public function setUser(string $user): void { $this->user = $user; } public function getUser(): string { return $this->user; } public function setPassword(string $password): void { $this->password = $password; } public function getPassword(): string { return $this->password; } } ``` ```php= <?php interface DatabaseConnectionInterface { public function setHost(string $host): void; public function getHost(): string; public function setUser(string $user): void; public function getUser(): string; public function setPassword(string $user): void; public function getPassword(): string; } ``` ```php= <?php namespace src\Сache; use DateTime; use Exception; use Psr\Cache\CacheItemPoolInterface; use Psr\Log\LoggerInterface; class CacheManager { /** * Объявление свойств в конструкторе * @param DatabaseConnectionInterface $logger * @param LoggerInterface $logger * @param CacheItemPoolInterface $cache * */ public function __construct( public DatabaseInterface $connection, public CacheItemPoolInterface $cache, public LoggerInterface $logger) {} public function setCache(array $input) { try { $cacheKey = $this->getCacheKey($input); $cacheItem = $this->cache->getItem($cacheKey); if ($cacheItem->isHit()) { return $cacheItem->get(); } $result = parent::get($input); $cacheItem ->set($result) ->expiresAt( (new DateTime())->modify('+1 day') ); return $result; } catch (Exception $e) { $this->logger->critical('Error'); } return []; } public function setCacheKey(array $input) { return json_encode($input); } } ```