Client::query()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace InfluxDB;
4
5
use InfluxDB\Adapter\WritableInterface as Writer;
6
use InfluxDB\Adapter\QueryableInterface as Reader;
7
8
/**
9
 * Client to manage request at InfluxDB
10
 */
11
class Client
12
{
13
    private $reader;
14
    private $writer;
15
16 14
    public function __construct(Reader $reader, Writer $writer)
17
    {
18 14
        $this->reader = $reader;
19 14
        $this->writer = $writer;
20 14
    }
21
22 12
    public function getReader()
23
    {
24 12
        return $this->reader;
25
    }
26
27 7
    public function getWriter()
28
    {
29 7
        return $this->writer;
30
    }
31
32 7
    public function mark($name, array $values = [])
33
    {
34 7
        $data = $name;
35 7
        if (!is_array($name)) {
36 5
            $data =[];
37 5
            $data['points'][0]['measurement'] = $name;
38 5
            $data['points'][0]['fields'] = $values;
39
        }
40
41 7
        return $this->getWriter()->send($data);
42
    }
43
44 12
    public function query($query)
45
    {
46 12
        return $this->getReader()->query($query);
47
    }
48
}