From 1ce67c5558d210963e02cbe48f4c3d4f1bea93b0 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 19 Sep 2015 17:59:26 +0200 Subject: [PATCH] Use trait insted of WriterAbstract In order to separate completely Http\Writer and Udp\Writer we could use `WriterTrait` instead of `WriterAbstract` and inheritance. This solution is more decoupled than the inheritance based solution. --- src/Adapter/Http/Writer.php | 7 +++++-- src/Adapter/Udp/Writer.php | 7 +++++-- src/Adapter/{WriterAbstract.php => WriterTrait.php} | 7 ++----- .../{WriterAbstractTest.php => WriterTraitTest.php} | 6 +++--- 4 files changed, 15 insertions(+), 12 deletions(-) rename src/Adapter/{WriterAbstract.php => WriterTrait.php} (91%) rename tests/unit/Adapter/{WriterAbstractTest.php => WriterTraitTest.php} (94%) diff --git a/src/Adapter/Http/Writer.php b/src/Adapter/Http/Writer.php index 9c1e518..8863c47 100644 --- a/src/Adapter/Http/Writer.php +++ b/src/Adapter/Http/Writer.php @@ -2,11 +2,14 @@ namespace InfluxDB\Adapter\Http; use GuzzleHttp\Client; +use InfluxDB\Adapter\WriterTrait; use InfluxDB\Adapter\Http\Options; -use InfluxDB\Adapter\WriterAbstract; +use InfluxDB\Adapter\WritableInterface; -class Writer extends WriterAbstract +class Writer implements WritableInterface { + use WriterTrait; + private $httpClient; private $options; diff --git a/src/Adapter/Udp/Writer.php b/src/Adapter/Udp/Writer.php index dbe49aa..7f19d77 100644 --- a/src/Adapter/Udp/Writer.php +++ b/src/Adapter/Udp/Writer.php @@ -1,11 +1,14 @@ getMockBuilder("InfluxDB\\Adapter\\WriterAbstract") - ->getMockForAbstractClass(); + $helper = $this->getMockBuilder("InfluxDB\\Adapter\\WriterTrait") + ->getMockForTrait(); $method = new ReflectionMethod(get_class($helper), "pointsToString"); $method->setAccessible(true);