for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace InfluxDB;
use InfluxDB\Adapter\WritableInterface as Writer;
use InfluxDB\Adapter\QueryableInterface as Reader;
/**
* Client to manage request at InfluxDB
*/
class Client
{
private $reader;
private $writer;
public function __construct(Reader $reader, Writer $writer)
$this->reader = $reader;
$this->writer = $writer;
}
public function getReader()
return $this->reader;
public function getWriter()
return $this->writer;
public function mark($name, array $values = [])
$data = $name;
if (!is_array($name)) {
$data = [];
$data['points'][0]['measurement'] = $name;
$data['points'][0]['fields'] = $values;
if (isset($data['tags'])) {
$tags = [];
foreach ($data['tags'] as $key => $value) {
$tags[$this->addSlashes($key)] = $this->addSlashes($value);
$data['tags'] = $tags;
if (isset($data['points'])) {
$points = [];
foreach ($data['points'] as $point) {
$fields = [];
foreach ($point['fields'] as $key => $value) {
$fields[$this->addSlashes($key)] = $value;
$point['fields'] = $fields;
array_push($points, $point);
$data['points'] = $points;
return $this->getWriter()->send($data);
public function query($query)
return $this->getReader()->query($query);
* Returns strings with space, comma, or equals sign characters backslashed per Influx write protocol syntax
*
* @param string $value
* @return string
private function addSlashes($value)
return str_replace([
' ',
',',
'='
], [
'\ ',
'\,',
'\='
], $value);