protected function createServiceConfig(string $name): array
    {
        $config = [];
        if ($this->has($name)) {
            $config = $this->config[$name];
        }

        $class = $name;

        if (isset($config['use'])) {
            if (!is_string($config['use'])) {
                throw new Exception\InvalidConfiguration('use must be a string for service '.$name);
            }

            $class = $config['use'] = $this->getEnv($config['use']);
        }

        if (preg_match('#^\{([^{}]+)\}$#', $class)) {
            $config = array_merge($this->getServiceDefaults(), $config);

            return $config;
        }

        $config = $this->mergeServiceConfig($name, $class, $config);

        if (isset($config['use'])) {
            $class = $config['use'] = $this->getEnv($config['use']);
        }

        if (!class_exists($class)) {
            throw new Exception\InvalidConfiguration('class '.$class.' is either not a class or can not be found');
        }

        return $config;
    }