Client   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 2
cbo 2
dl 0
loc 38
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getReader() 0 4 1
A getWriter() 0 4 1
A query() 0 4 1
A mark() 0 11 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
}