Passed
Pull Request — master (#18)
by Timon
08:58
created

Options   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 35
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setDb() 0 9 1
A jsonSerialize() 0 10 2
1
<?php
2
declare(strict_types=1);
3
4
namespace TBolier\RethinkQL\Query;
5
6
use TBolier\RethinkQL\Types\Term\TermType;
7
8
class Options implements OptionsInterface
9
{
10
    /**
11
     * @var array
12
     */
13
    private $db;
14
15
    /**
16
     * @param string $name
17
     * @return OptionsInterface
18
     */
19 27
    public function setDb(string $name): OptionsInterface
20
    {
21 27
        $this->db = [
22 27
            TermType::DB,
23 27
            [$name],
24
        ];
25
26 27
        return $this;
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32 16
    public function jsonSerialize()
33
    {
34 16
        if (empty($this->db)) {
35
            return [];
36
        }
37
38
        return [
39 16
            'db' => $this->db
40
        ];
41
    }
42
}
43