Passed
Pull Request — master (#18)
by Marc
03:37
created

Options::jsonSerialize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 3
cts 4
cp 0.75
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 2.0625
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