registry = $registry; $that->defaultManagerName = $managerName; return $that; } private function __construct() { } public function getEntityManager(?string $name = null): EntityManagerInterface { $managerName = $name ?? $this->defaultManagerName; $em = $this->registry->getManager($managerName); if (! $em instanceof EntityManagerInterface) { throw InvalidConfiguration::invalidManagerType($em); } return $em; } }