From c52377aad1431aceb8868ccdc6bb82acb3774bbc Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Jun 2015 12:04:04 +0200 Subject: [PATCH] Allows non write adapters * Renamed `AdapterInterface` to `WritableInterface` * Constructor now allows different adapter implementations * Check that adapter implements `WritableInterface` during data send --- src/Adapter/AdapterAbstract.php | 9 ++------- src/Adapter/AdapterInterface.php | 15 --------------- src/Adapter/WritableInterface.php | 7 +++++++ src/Client.php | 7 ++++++- 4 files changed, 15 insertions(+), 23 deletions(-) delete mode 100644 src/Adapter/AdapterInterface.php create mode 100644 src/Adapter/WritableInterface.php diff --git a/src/Adapter/AdapterAbstract.php b/src/Adapter/AdapterAbstract.php index b03d47681..342b40bda 100644 --- a/src/Adapter/AdapterAbstract.php +++ b/src/Adapter/AdapterAbstract.php @@ -2,22 +2,17 @@ namespace InfluxDB\Adapter; use InfluxDB\Options; +use InfluxDB\Adapter\WritableInterface; -abstract class AdapterAbstract implements AdapterInterface +abstract class AdapterAbstract implements WritableInterface { private $options; - /** - * @param Options $options - */ public function __construct(Options $options) { $this->options = $options; } - /** - * @return Options - */ public function getOptions() { return $this->options; diff --git a/src/Adapter/AdapterInterface.php b/src/Adapter/AdapterInterface.php deleted file mode 100644 index 23bdf7a68..000000000 --- a/src/Adapter/AdapterInterface.php +++ /dev/null @@ -1,15 +0,0 @@ -adapter = $adapter; return $this; @@ -24,6 +25,10 @@ class Client public function mark($name, array $values = []) { + if (!($this->getAdapter() instanceOf WritableInterface)) { + throw new \BadMethodCallException("You can write data to database only if the adapter supports it!"); + } + $data = $name; if (!is_array($name)) { $data =[];