From 55275d2d7505f36b38c594cb0d3679af0a371202 Mon Sep 17 00:00:00 2001 From: Aldarien Date: Fri, 9 Sep 2022 10:31:38 -0400 Subject: [PATCH] Factory Implementation --- src/Implement/Model/Factory.php | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/Implement/Model/Factory.php diff --git a/src/Implement/Model/Factory.php b/src/Implement/Model/Factory.php new file mode 100644 index 0000000..c5472f9 --- /dev/null +++ b/src/Implement/Model/Factory.php @@ -0,0 +1,46 @@ +setContainer($container); + } + + protected ContainerInterface $container; + public function setContainer(ContainerInterface $container): FactoryInterface + { + $this->container = $container; + return $this; + } + public function getContainer(): ContainerInterface + { + return $this->container; + } + protected string $namespace; + public function setNamespace(string $namespace): FactoryInterface + { + $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)); + } +}