Passed
Push — main ( 83bea6...22b11c )
by Thierry
01:32
created

Connection   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 110
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 110
rs 10
wmc 15

11 Methods

Rating   Name   Duplication   Size   Complexity  
A result() 0 10 4
A query() 0 3 1
A open() 0 2 1
A multiQuery() 0 2 1
A rows() 0 6 2
A serverInfo() 0 3 1
A nextResult() 0 2 1
A setNextResultStatus() 0 3 1
A setServerInfo() 0 3 1
A storedResult() 0 2 1
A setNextResultValues() 0 3 1
1
<?php
2
3
namespace Lagdo\DbAdmin\Driver\Fake;
4
5
use Lagdo\DbAdmin\Driver\Db\Connection as AbstractConnection;
6
7
use function count;
8
9
/**
10
 * Fake Connection class for testing
11
 */
12
class Connection extends AbstractConnection
13
{
14
    /**
15
     * @var string
16
     */
17
    protected $serverInfo = '';
18
19
    /**
20
     * @param string $serverInfo
21
     *
22
     * @return void
23
     */
24
    public function setServerInfo(string $serverInfo)
25
    {
26
        $this->serverInfo = $serverInfo;
27
    }
28
29
    /**
30
     * @param array $values
31
     *
32
     * @return void
33
     */
34
    public function setNextResultValues(array $values)
35
    {
36
        $this->statement = new Statement($values);
37
    }
38
39
    /**
40
     * @param bool $status
41
     *
42
     * @return void
43
     */
44
    public function setNextResultStatus(bool $status)
45
    {
46
        $this->statement = $status;
47
    }
48
49
    /**
50
     * @inheritDoc
51
     */
52
    public function serverInfo()
53
    {
54
        return $this->serverInfo;
55
    }
56
57
    /**
58
     * @inheritDoc
59
     */
60
    public function open(string $database, string $schema = '')
61
    {
62
        // TODO: Implement open() method.
63
    }
64
65
    /**
66
     * @inheritDoc
67
     */
68
    public function query(string $query, bool $unbuffered = false)
69
    {
70
        return $this->statement;
71
    }
72
73
    /**
74
     * @inheritDoc
75
     */
76
    public function result(string $query, int $field = -1)
77
    {
78
        if ($field < 0) {
79
            $field = $this->defaultField();
80
        }
81
        if (!is_a($this->statement, Statement::class)) {
82
            return null;
83
        }
84
        $row = $this->statement->fetchRow();
85
        return count($row) > $field ? $row[$field] : null;
86
    }
87
88
    /**
89
     * @param string $query
90
     *
91
     * @return array
92
     */
93
    public function rows(string $query): array
0 ignored issues
show
Unused Code introduced by
The parameter $query is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

93
    public function rows(/** @scrutinizer ignore-unused */ string $query): array

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
94
    {
95
        if (!is_a($this->statement, Statement::class)) {
96
            return [];
97
        }
98
        return $this->statement->rows();
99
    }
100
101
    /**
102
     * @inheritDoc
103
     */
104
    public function multiQuery(string $query)
105
    {
106
        // TODO: Implement multiQuery() method.
107
    }
108
109
    /**
110
     * @inheritDoc
111
     */
112
    public function storedResult()
113
    {
114
        // TODO: Implement storedResult() method.
115
    }
116
117
    /**
118
     * @inheritDoc
119
     */
120
    public function nextResult()
121
    {
122
        // TODO: Implement nextResult() method.
123
    }
124
}
125