How to check config setting in custom service class with dependency injection? In a custom Service class, I need to check a config setting.
I'm able to do this using \Drupal::config(static::SETTINGS) as documented here: https://www.drupal.org/docs/drupal-apis/configuration-api/working-with-configuration-forms
but Coder complains:

WARNING | \Drupal calls should be avoided in classes, use dependency injection instead

What service should I inject here?
I only need to see the immutable config value, I don't think I need a ConfigFactory.
More info:
When I try to inject the ConfigFactoryInterface, using the pattern I have followed for many other services, I get this error:

Error: Call to undefined method Drupal\my_custom_module\Api\DataPartner::config() in Drupal\my_custom_module\Api\DataPartner-&gt;hasDebugPermission()

The code in the hasDebugPermission() method looks like this:
  /**
   * Private function to control whether displaying debug info is permitted.
   *
   * @return bool
   *   TRUE if debugging is permitted for current user in current environment.
   */
  private function hasDebugPermission() {
    $config = $this-&gt;config(static::SETTINGS);
    $result = DATA_PARTNER_FORMS_DEBUG
      &amp;&amp; $config-&gt;get('display_debugging_info')
      &amp;&amp; $this-&gt;account-&gt;hasPermission('debug forms');
    return $result;
  }

And I have declared static::SETTINGS like this:
  /**
   * Config settings.
   *
   * @var string
   */
  private const SETTINGS = 'my_custom_module.settings';

The call to $this-&gt;account-&gt;hasPermission() works fine after injecting \Drupal\Core\Session\AccountInterface, but the call to $this-&gt;config('my_custom_module.settings')-&gt;get('display_debugging_info') does not work after injecting \Drupal\Core\Config\ConfigFactoryInterface.
Make sure you inject config.factory and then you need to use:
$this-&gt;config
  -&gt;get('my_custom_module.settings')
  -&gt;get('display_debugging_info');

You can see that Drupal::config() is:
public static function config($name) {
  return static::getContainer()
    -&gt;get('config.factory')
    -&gt;get($name);
}

So after injecting your service, the equivalent of \Drupal::config('my_custom_module.settings') is:
$this-&gt;config-&gt;get('my_custom_module.settings');