From 9834eb70a46283c8d381e675308053bb48602d7e Mon Sep 17 00:00:00 2001 From: Aldarien Date: Fri, 9 Sep 2022 13:15:11 -0400 Subject: [PATCH] Use full class name without having to specify namespace beforehand --- src/Concept/Model/Factory.php | 4 +--- src/Implement/Model/Factory.php | 21 ++------------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/Concept/Model/Factory.php b/src/Concept/Model/Factory.php index d92b166..8e1f566 100644 --- a/src/Concept/Model/Factory.php +++ b/src/Concept/Model/Factory.php @@ -7,7 +7,5 @@ interface Factory { public function setContainer(ContainerInterface $container): Factory; public function getContainer(): ContainerInterface; - public function setNamespace(string $namespace): Factory; - public function getNamespace(): string; - public function get(string $repository_name): Repository; + public function get(string $repository_class): Repository; } diff --git a/src/Implement/Model/Factory.php b/src/Implement/Model/Factory.php index c5472f9..c172593 100644 --- a/src/Implement/Model/Factory.php +++ b/src/Implement/Model/Factory.php @@ -22,25 +22,8 @@ class Factory implements FactoryInterface { return $this->container; } - protected string $namespace; - public function setNamespace(string $namespace): FactoryInterface + public function get(string $repository_class): Repository { - $this->namespace = $namespace; - return $this; - } - public function getNamespace(): string - { - return $this->namespace; - } - protected function buildRepository(string $repository_name): string - { - return implode("\\", [ - $this->getNamespace(), - $repository_name - ]); - } - public function get(string $repository_name): Repository - { - return $this->getContainer()->get($this->buildRepository($repository_name)); + return $this->getContainer()->get($repository_class); } }