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

Options::setDb()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 1
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