4 Commits

Author SHA1 Message Date
81ad81f7bf v1.1.0 2022-09-09 10:33:54 -04:00
7fc7de7390 Added Factory implementation 2022-09-09 10:33:19 -04:00
55275d2d75 Factory Implementation 2022-09-09 10:31:38 -04:00
12065b376b v2.0.0 2022-09-08 21:43:02 -04:00

View File

@ -0,0 +1,46 @@
<?php
namespace ProVM\Implement\Model;
use Psr\Container\ContainerInterface;
use ProVM\Concept\Model\Factory as FactoryInterface;
use ProVM\Concept\Model\Repository;
class Factory implements FactoryInterface
{
public function __construct(ContainerInterface $container)
{
$this->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));
}
}