protected function resolveClass(?ContainerInterface $container = null, string $class)
    {
        if ($container instanceof ContainerInterface && $container->has($class)) {
            return $container->get($class);
        }

        return new $class();
    }