From 62be02a5ce7a60a54b672f48046c767a22d84f8d Mon Sep 17 00:00:00 2001 From: Rafael Dohms Date: Fri, 17 Nov 2017 14:36:13 +0100 Subject: [PATCH] Extract Interfaces for User Interaction Classes The registry and the rederer are classes that are usually injected by users into their own code, having interfaces for them allow users to mock based on the API and not on the concret implementation which avoids a common code smell. This also allows better custom implementations if users so desire. --- src/Prometheus/CollectorRegistry.php | 2 +- src/Prometheus/RegistryInterface.php | 106 +++++++++++++++++++++++++++ src/Prometheus/RenderTextFormat.php | 2 +- src/Prometheus/RendererInterface.php | 14 ++++ 4 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 src/Prometheus/RegistryInterface.php create mode 100644 src/Prometheus/RendererInterface.php diff --git a/src/Prometheus/CollectorRegistry.php b/src/Prometheus/CollectorRegistry.php index 9ff18e3..23e0965 100644 --- a/src/Prometheus/CollectorRegistry.php +++ b/src/Prometheus/CollectorRegistry.php @@ -9,7 +9,7 @@ use Prometheus\Storage\Adapter; use Prometheus\Storage\Redis; -class CollectorRegistry +class CollectorRegistry implements RegistryInterface { /** * @var CollectorRegistry diff --git a/src/Prometheus/RegistryInterface.php b/src/Prometheus/RegistryInterface.php new file mode 100644 index 0000000..7bae64d --- /dev/null +++ b/src/Prometheus/RegistryInterface.php @@ -0,0 +1,106 @@ +