This allows extending the class by creating child classes simpler: calls like StatsD::timing() are essentially equivalent to adding a "final" modifier. By creating an instance in a factory class (statsd_instance in the suggested patch), any module wishing to implement an alternate version may just implement its own factory, create a derived class, and everything will still work using the new class overrides instead of the original method when they exist.

This also makes unit testing simpler, making mocks possible.

The suggested patch also adds a new-style (PSR-0, à la Drupal 8) test suite.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fgm’s picture

Status: Active » Needs review
Issue tags: +PSR-0
FileSize
13.96 KB

Suggested patch applies on top of #2023431: Make module pass coder/codesniffer review, and also fixes an error in statsd_uninstall, which invoke "variabel_del" instead of "variable_del".

Nick_vh’s picture

Let's make a new branch with this patch as it breaks compatibility with the current version and people's site will break if they just upgrade with this patch.