get($id); if (!$factory instanceof FlasherInterface && !$factory instanceof NotificationFactoryInterface) { throw new \InvalidArgumentException(\sprintf('Expected an instance of "%s" or "%s", got "%s".', FlasherInterface::class, NotificationFactoryInterface::class, get_debug_type($factory))); } return $factory; } public static function has(string $id): bool { return self::getContainer()->has($id); } public static function getContainer(): ContainerInterface { $container = self::getInstance()->container; $resolved = $container instanceof \Closure || \is_callable($container) ? $container() : $container; if (!$resolved instanceof ContainerInterface) { throw new \InvalidArgumentException(\sprintf('Expected an instance of "%s", got "%s".', ContainerInterface::class, get_debug_type($resolved))); } return $resolved; } private static function getInstance(): self { if (!self::$instance instanceof self) { throw new \LogicException('FlasherContainer has not been initialized. Please initialize it by calling FlasherContainer::from(ContainerInterface $container).'); } return self::$instance; } }