public static function getInstance($engineName, ConfigObject $config)
    {
        $driver = static::getLibrary($engineName);

        if (!self::isString($driver)) {
            throw new TemplateEngineException('Invalid driver returned for ' . $engineName . ' engine');
        }

        try {
            $instance = new $driver($config);
        } catch (\Exception $e) {
            throw $e;
        }

        if (!self::isInstanceOf($instance, TemplateEngineInterface::class)) {
            throw new TemplateEngineException(TemplateEngineException::MSG_INVALID_ARG, ['driver', TemplateEngineInterface::class]);
        }

        return $instance;
    }