Passed
Pull Request — master (#9)
by Timon
09:13
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
3
namespace TBolier\RethinkQL\Query;
4
5
use TBolier\RethinkQL\Types\Term\TermType;
6
7
class Options implements OptionsInterface
8
{
9
    private $db;
10
11 13
    public function setDb(string $name): OptionsInterface
12
    {
13 13
        $this->db = [
14 13
            TermType::DB,
15 13
            [$name],
16
        ];
17
18 13
        return $this;
19
    }
20
21
    /**
22
     * Specify data which should be serialized to JSON
23
     * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
24
     * @return mixed data which can be serialized by <b>json_encode</b>,
25
     * which is a value of any type other than a resource.
26
     * @since 5.4.0
27
     */
28 13
    public function jsonSerialize()
29
    {
30
        return [
31 13
            'db' => $this->db
32
        ];
33
    }
34
}
35