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
|
|||
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 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.