Skip to content

Commit 55e20e2

Browse files
committed
Merge pull request #62 from corley/feature/adapter-abstract-refactor
Use trait insted of WriterAbstract
2 parents 5da19f7 + 1ce67c5 commit 55e20e2

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

src/Adapter/Http/Writer.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
namespace InfluxDB\Adapter\Http;
33

44
use GuzzleHttp\Client;
5+
use InfluxDB\Adapter\WriterTrait;
56
use InfluxDB\Adapter\Http\Options;
6-
use InfluxDB\Adapter\WriterAbstract;
7+
use InfluxDB\Adapter\WritableInterface;
78

8-
class Writer extends WriterAbstract
9+
class Writer implements WritableInterface
910
{
11+
use WriterTrait;
12+
1013
private $httpClient;
1114
private $options;
1215

src/Adapter/Udp/Writer.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<?php
22
namespace InfluxDB\Adapter\Udp;
33

4-
use InfluxDB\Adapter\WriterAbstract;
4+
use InfluxDB\Adapter\WriterTrait;
55
use InfluxDB\Adapter\Udp\Options;
6+
use InfluxDB\Adapter\WritableInterface;
67

7-
class Writer extends WriterAbstract
8+
class Writer implements WritableInterface
89
{
10+
use WriterTrait;
11+
912
private $options;
1013

1114
public function __construct(Options $options)

src/Adapter/WriterAbstract.php renamed to src/Adapter/WriterTrait.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22
namespace InfluxDB\Adapter;
33

44
use DateTime;
5-
use InfluxDB\Adapter\WritableInterface;
65

7-
abstract class WriterAbstract implements WritableInterface
6+
trait WriterTrait
87
{
9-
abstract public function send(array $message);
10-
11-
protected function messageToLineProtocol(array $message, array $tags = [])
8+
public function messageToLineProtocol(array $message, array $tags = [])
129
{
1310
if (!array_key_exists("points", $message)) {
1411
return;

tests/unit/Adapter/WriterAbstractTest.php renamed to tests/unit/Adapter/WriterTraitTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
use InfluxDB\Type\IntType;
66
use InfluxDB\Type\FloatType;
77

8-
class WriterAbstractTest extends \PHPUnit_Framework_TestCase
8+
class WriterTraitTest extends \PHPUnit_Framework_TestCase
99
{
1010
/**
1111
* @dataProvider getElements
1212
*/
1313
public function testListToLineValues($message, $result)
1414
{
15-
$helper = $this->getMockBuilder("InfluxDB\\Adapter\\WriterAbstract")
16-
->getMockForAbstractClass();
15+
$helper = $this->getMockBuilder("InfluxDB\\Adapter\\WriterTrait")
16+
->getMockForTrait();
1717

1818
$method = new ReflectionMethod(get_class($helper), "pointsToString");
1919
$method->setAccessible(true);

0 commit comments

Comments
 (0)