Skip to content

Commit

Permalink
Merge pull request #62 from corley/feature/adapter-abstract-refactor
Browse files Browse the repository at this point in the history
Use trait insted of WriterAbstract
  • Loading branch information
wdalmut committed Sep 19, 2015
2 parents 5da19f7 + 1ce67c5 commit 55e20e2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
7 changes: 5 additions & 2 deletions src/Adapter/Http/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 5 additions & 2 deletions src/Adapter/Udp/Writer.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?php
namespace InfluxDB\Adapter\Udp;

use InfluxDB\Adapter\WriterAbstract;
use InfluxDB\Adapter\WriterTrait;
use InfluxDB\Adapter\Udp\Options;
use InfluxDB\Adapter\WritableInterface;

class Writer extends WriterAbstract
class Writer implements WritableInterface
{
use WriterTrait;

private $options;

public function __construct(Options $options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
namespace InfluxDB\Adapter;

use DateTime;
use InfluxDB\Adapter\WritableInterface;

abstract class WriterAbstract implements WritableInterface
trait WriterTrait
{
abstract public function send(array $message);

protected function messageToLineProtocol(array $message, array $tags = [])
public function messageToLineProtocol(array $message, array $tags = [])
{
if (!array_key_exists("points", $message)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
use InfluxDB\Type\IntType;
use InfluxDB\Type\FloatType;

class WriterAbstractTest extends \PHPUnit_Framework_TestCase
class WriterTraitTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider getElements
*/
public function testListToLineValues($message, $result)
{
$helper = $this->getMockBuilder("InfluxDB\\Adapter\\WriterAbstract")
->getMockForAbstractClass();
$helper = $this->getMockBuilder("InfluxDB\\Adapter\\WriterTrait")
->getMockForTrait();

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

0 comments on commit 55e20e2

Please sign in to comment.