Passed
Pull Request — master (#34)
by Marc
05:44
created

Database   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
dl 0
loc 84
c 0
b 0
f 0
ccs 24
cts 24
cp 1
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A dbDrop() 0 5 1
A toArray() 0 3 1
A tableList() 0 5 1
A __construct() 0 5 1
A tableCreate() 0 5 1
A dbList() 0 5 1
A tableDrop() 0 5 1
A dbCreate() 0 5 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace TBolier\RethinkQL\Query;
5
6
use TBolier\RethinkQL\Message\MessageInterface;
7
use TBolier\RethinkQL\Query\Operation\DbCreate;
8
use TBolier\RethinkQL\Query\Operation\DbDrop;
9
use TBolier\RethinkQL\Query\Operation\DbList;
10
use TBolier\RethinkQL\Query\Operation\TableCreate;
11
use TBolier\RethinkQL\Query\Operation\TableDrop;
12
use TBolier\RethinkQL\Query\Operation\TableList;
13
use TBolier\RethinkQL\RethinkInterface;
14
15
class Database extends AbstractQuery implements DatabaseInterface
16
{
17
    /**
18
     * @var QueryInterface
19
     */
20
    private $query;
21
22
    /**
23
     * @param RethinkInterface $rethink
24
     * @param MessageInterface $message
25
     */
26 14
    public function __construct(RethinkInterface $rethink, MessageInterface $message)
27
    {
28 14
        parent::__construct($rethink, $message);
29
30 14
        $this->dbList();
31 14
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36 13
    public function dbCreate(string $name): DatabaseInterface
37
    {
38 13
        $this->query = new DbCreate($this->rethink, $this->message, $name);
39
40 13
        return $this;
41
    }
42
43
    /**
44
     * @inheritdoc
45
     */
46 14
    public function dbDrop(string $name): DatabaseInterface
47
    {
48 14
        $this->query = new DbDrop($this->rethink, $this->message, $name);
49
50 14
        return $this;
51
    }
52
53
    /**
54
     * @inheritdoc
55
     */
56 14
    public function dbList(): DatabaseInterface
57
    {
58 14
        $this->query = new DbList($this->rethink, $this->message);
59
60 14
        return $this;
61
    }
62
63
    /**
64
     * @inheritdoc
65
     */
66 12
    public function tableList(): DatabaseInterface
67
    {
68 12
        $this->query = new TableList($this->rethink, $this->message);
69
70 12
        return $this;
71
    }
72
73
    /**
74
     * @inheritdoc
75
     */
76 13
    public function tableCreate(string $name): DatabaseInterface
77
    {
78 13
        $this->query = new TableCreate($this->rethink, $this->message, $name);
79
80 13
        return $this;
81
    }
82
83
    /**
84
     * @inheritdoc
85
     */
86 12
    public function tableDrop(string $name): DatabaseInterface
87
    {
88 12
        $this->query = new TableDrop($this->rethink, $this->message, $name);
89
90 12
        return $this;
91
    }
92
93
    /**
94
     * @inheritdoc
95
     */
96 14
    public function toArray(): array
97
    {
98 14
        return $this->query->toArray();
99
    }
100
}
101