Client::mark()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 2
crap 2
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
}