protected function buildResolver($config)
    {
        if (is_string($config)) {
            $config = [
                'className' => $config
            ];
        }

        if (!isset($config['className'])) {
            $message = 'Option `className` is not present.';
            throw new InvalidArgumentException($message);
        }

        $class = App::className($config['className'], 'Identifier/Resolver', 'Resolver');
        if ($class === false) {
            $message = sprintf('Resolver class `%s` does not exist.', $config['className']);
            throw new InvalidArgumentException($message);
        }
        $instance = new $class($config);

        if (!($instance instanceof ResolverInterface)) {
            $message = sprintf('Resolver must implement `%s`.', ResolverInterface::class);
            throw new RuntimeException($message);
        }

        return $instance;
    }