public static function setConfig(array $config)
    {
        if (! isset($config['adapters']) || ! is_array($config['adapters'])) {
            throw new DomainException(
                'Missing adapters configuration.'
            );
        }

        $defaultAdapter = static::DEFAULT_ADAPTER;
        if (isset($config['defaults']['adapter'])) {
            $defaultAdapter = $config['defaults']['adapter'];
        }
        if (! isset($config['adapters'][$defaultAdapter])) {
            throw new DomainException(sprintf(
                'Missing configuration of default adapter "%s".',
                $defaultAdapter
            ));
        }

        foreach ($config['adapters'] as $adapter => $items) {
            if (! isset($items['class'])) {
                throw new DomainException(sprintf(
                    'The class of adapter "%s" is not specified.',
                    $adapter
                ));
            }
        }
        static::$config = $config;
    }