refactor: Замена строк на имена классов

This commit is contained in:
origami11@yandex.ru 2024-12-16 17:10:44 +03:00
parent 1d22953f68
commit 82f6dd1630
4 changed files with 30 additions and 18 deletions

View file

@ -11,21 +11,21 @@ class Factory
public $config;
public $user;
public function __construct (Database $db, Registry $config = null, User $user = null)
public function __construct(Database $db, Registry $config = null, User $user = null)
{
$this->db = $db;
$this->config = $config;
$this->user = $user;
}
/**
* Создает модель
* @param string $name
* @return BaseMapper
* @template T
* @param class-string<T> $modelName
* @return T
*/
public function getModel ($name)
public function getModel($modelName)
{
$modelName = "App\\Mapper\\" . $name;
$model = new $modelName();
$model->db = $this->db;
$model->factory = $this;