Options::jsonSerialize()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 8
rs 10
ccs 2
cts 2
cp 1
cc 2
nc 2
nop 0
crap 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
    public function setDb(string $name): OptionsInterface
16
    {
17
        $this->db = [
18
            TermType::DB,
19 28
            [$name],
20
        ];
21 28
22 28
        return $this;
23 28
    }
24
25
    public function jsonSerialize()
26 28
    {
27
        if (empty($this->db)) {
28
            return [];
29
        }
30
31
        return [
32 17
            'db' => $this->db
33
        ];
34 17
    }
35
}
36