Passed
Push — master ( e0d17a...139da0 )
by Michel
03:37
created

Builder::row()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
ccs 0
cts 0
cp 0
rs 9.4285
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace TBolier\RethinkQL\Query;
5
6
use TBolier\RethinkQL\Message\Message;
7
use TBolier\RethinkQL\Message\MessageInterface;
8
use TBolier\RethinkQL\Query\Manipulation\ManipulationInterface;
9
use TBolier\RethinkQL\RethinkInterface;
10
11
class Builder implements BuilderInterface
12
{
13
    /**
14
     * @var DatabaseInterface
15
     */
16
    private $database;
17
18
    /**
19
     * @var MessageInterface
20
     */
21
    private $message;
0 ignored issues
show
introduced by
The private property $message is not used, and could be removed.
Loading history...
22
23
    /**
24
     * @var OrdeningInterface
25
     */
26
    private $ordering;
27
28
    /**
29
     * @var RethinkInterface
30
     */
31
    private $rethink;
32
33
    /**
34
     * @var ManipulationInterface
35 14
     */
36
    private $row;
37 14
38 14
    /**
39 14
     * @var Table
40
     */
41
    private $table;
42
43
    /**
44
     * @param RethinkInterface $rethink
45 11
     */
46
    public function __construct(RethinkInterface $rethink)
47 11
    {
48 8
        $this->rethink = $rethink;
49
    }
50
51 11
    /**
52
     * @param string $name
53 11
     * @return TableInterface
54
     */
55
    public function table(string $name): TableInterface
56
    {
57
        if ($this->table) {
58
            unset($this->table);
59 14
        }
60
61 14
        $this->table = new Table($name, $this->rethink, new Message());
62 14
63
        return $this->table;
64
    }
65 14
66
    /**
67 14
     * @return DatabaseInterface
68
     */
69
    public function database(): DatabaseInterface
70
    {
71
        if ($this->database) {
72
            unset($this->database);
73
        }
74
75
        $this->database = new Database($this->rethink, new Message());
76
77
        return $this->database;
78
    }
79
80
    /**
81
     * @param string $key
82
     * @return OrdeningInterface
83
     */
84
    public function ordening(string $key): OrdeningInterface
85
    {
86
        if ($this->ordering) {
87
            unset($this->ordering);
88
        }
89
90
        $this->ordering = new Ordening($key, $this->rethink, new Message());
91
92
        return $this->ordering;
93
    }
94
95
    /**
96
     * @param string $value
97
     * @return ManipulationInterface
98
     */
99
    public function row(string $value): ManipulationInterface
100
    {
101
        $this->row = new Row($this->rethink, new Message(), $value);
102
103
        return $this->row;
104
    }
105
}
106