From 945c95441f1512c0fbcaee24cf84fd36e765aa43 Mon Sep 17 00:00:00 2001 From: User Date: Fri, 21 Mar 2025 21:46:19 +0300 Subject: [PATCH] 20250321#1 --- src/Mysql/MysqlStorage.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Mysql/MysqlStorage.php b/src/Mysql/MysqlStorage.php index 14810d4..7e5021c 100644 --- a/src/Mysql/MysqlStorage.php +++ b/src/Mysql/MysqlStorage.php @@ -15,17 +15,24 @@ class MysqlStorage implements MysqlStorageInterface { /** * Внутренний конструктор подключения к БД * Mysql constructor. - * @param array $params + * @param object $params * @throws Exception */ - public function __construct(array $params) { - $this->mysqli = new mysqli($params['host'], $params['user'], $params['pass'], $params['base']); + public function __construct( + private readonly object $params + ) { + $this->mysqli = new mysqli( + $this->params->host, + $this->params->user, + $this->params->pass, + $this->params->base + ); // выводим ошибку при неудачном подключении if ($this->mysqli->connect_errno) { throw new Exception($this->mysqli->connect_errno); } $this->mysqli->set_charset("utf8"); - if(!empty($params['logsEnable'])) $this->logsEnabled = true; + if(!empty($this->params->logsEnable)) $this->logsEnabled = true; } /** @inheritDoc */