This commit is contained in:
2022-06-13 21:36:52 -04:00
parent 3580738273
commit 42a97bb074
100 changed files with 2574 additions and 313 deletions

View File

@ -0,0 +1,30 @@
<?php
namespace Incoviba\API\Common\Alias;
use Incoviba\API\Common\Define\Controller\Json;
use Incoviba\API\Common\Factory\Mapper as MapperFactory;
use Incoviba\Mapper\Mapper;
class Controller
{
use Json;
protected MapperFactory $mapperFactory;
public function __construct(MapperFactory $mapperFactory) {
$this->mapperFactory = $mapperFactory;
}
protected array $mappers;
public function getMapper(string $name): Mapper
{
if (!class_exists($name)) {
throw new \InvalidArgumentException("Mapper {$name} not found.");
}
if (!isset($this->mappers)) {
$this->mappers = [];
}
if (!isset($this->mappers[$name])) {
$this->mappers[$name] = $this->mapperFactory->get($name);
}
return $this->mappers[$name];
}
}