Passed
Pull Request — master (#18)
by Marc
03:37
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 25
    public function setDb(string $name): OptionsInterface
20
    {
21 25
        $this->db = [
22 25
            TermType::DB,
23 25
            [$name],
24
        ];
25
26 25
        return $this;
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32 14
    public function jsonSerialize()
33
    {
34 14
        if (empty($this->db)) {
35
            return [];
36
        }
37
38
        return [
39 14
            'db' => $this->db
40
        ];
41
    }
42
}
43