| Total Complexity | 4 |
| Total Lines | 23 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | class EntityManagerPool implements EntityManagerPoolInterface |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * @param array<string, EntityManagerInterface> $entityManagerPool |
||
| 26 | */ |
||
| 27 | 3 | public function __construct( |
|
| 28 | private readonly EntityManagerFactoryInterface $entityManagerFactory, |
||
| 29 | private array $entityManagerPool = [] |
||
| 30 | ) { |
||
| 31 | 3 | } |
|
| 32 | |||
| 33 | 2 | public function getManager(string $name): EntityManagerInterface |
|
| 34 | { |
||
| 35 | 2 | if (!\array_key_exists($name, $this->entityManagerPool)) { |
|
| 36 | 2 | $this->entityManagerPool[$name] = $this->entityManagerFactory->create($name); |
|
| 37 | } |
||
| 38 | |||
| 39 | 2 | return $this->entityManagerPool[$name]; |
|
| 40 | } |
||
| 41 | |||
| 42 | 1 | public function getDefaultManager(): EntityManagerInterface |
|
| 45 | } |
||
| 46 | } |
||
| 47 |