Passed
Pull Request — master (#160)
by Dmitriy
02:31
created

ConnectionInterfaceProxy::getServerVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Collector\Database;
6
7
use Closure;
8
use Yiisoft\Cache\Dependency\Dependency;
9
use Yiisoft\Db\Command\CommandInterface;
10
use Yiisoft\Db\Connection\ConnectionInterface;
11
use Yiisoft\Db\Profiler\ProfilerInterface;
12
use Yiisoft\Db\Query\BatchQueryResultInterface;
13
use Yiisoft\Db\Query\QueryInterface;
14
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
15
use Yiisoft\Db\Schema\QuoterInterface;
16
use Yiisoft\Db\Schema\SchemaInterface;
17
use Yiisoft\Db\Schema\TableSchemaInterface;
18
use Yiisoft\Db\Transaction\TransactionInterface;
19
20
final class ConnectionInterfaceProxy implements ConnectionInterface
21
{
22
    public function __construct(
23
        private ConnectionInterface $connection,
24
        private DatabaseCollector $collector
25
    ) {
26
    }
27
28
    public function beginTransaction(string $isolationLevel = null): TransactionInterface
29
    {
30
        return $this->connection->beginTransaction($isolationLevel);
31
    }
32
33
    public function cache(Closure $closure, int $duration = null, Dependency $dependency = null): mixed
34
    {
35
        return $this->connection->cache($closure, $duration, $dependency);
0 ignored issues
show
Bug introduced by
The method cache() does not exist on Yiisoft\Db\Connection\ConnectionInterface. It seems like you code against a sub-type of Yiisoft\Db\Connection\ConnectionInterface such as Yiisoft\Yii\Debug\Collec...onnectionInterfaceProxy. ( Ignorable by Annotation )

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

35
        return $this->connection->/** @scrutinizer ignore-call */ cache($closure, $duration, $dependency);
Loading history...
36
    }
37
38
    public function createBatchQueryResult(QueryInterface $query, bool $each = false): BatchQueryResultInterface
39
    {
40
        return $this->connection->createBatchQueryResult($query, $each);
41
    }
42
43
    public function createCommand(string $sql = null, array $params = []): CommandInterface
44
    {
45
        [$callStack] = debug_backtrace();
46
47
        $this->collector->collect($sql, $params, $callStack['file'] . ':' . $callStack['line']);
0 ignored issues
show
Bug introduced by
It seems like $sql can also be of type null; however, parameter $sql of Yiisoft\Yii\Debug\Collec...aseCollector::collect() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

47
        $this->collector->collect(/** @scrutinizer ignore-type */ $sql, $params, $callStack['file'] . ':' . $callStack['line']);
Loading history...
48
49
        return $this->connection->createCommand($sql, $params);
50
    }
51
52
    public function createTransaction(): TransactionInterface
53
    {
54
        return $this->connection->createTransaction();
55
    }
56
57
    public function close(): void
58
    {
59
        $this->connection->close();
60
    }
61
62
    public function getCacheKey(): array
63
    {
64
        return $this->connection->getCacheKey();
65
    }
66
67
    public function getName(): string
68
    {
69
        return $this->connection->getName();
70
    }
71
72
    public function getLastInsertID(string $sequenceName = null): string
73
    {
74
        return $this->connection->getLastInsertID($sequenceName);
75
    }
76
77
    public function getQueryBuilder(): QueryBuilderInterface
78
    {
79
        return $this->connection->getQueryBuilder();
80
    }
81
82
    public function getQuoter(): QuoterInterface
83
    {
84
        return $this->connection->getQuoter();
85
    }
86
87
    public function getSchema(): SchemaInterface
88
    {
89
        return $this->connection->getSchema();
90
    }
91
92
    public function getServerVersion(): string
93
    {
94
        return $this->connection->getServerVersion();
95
    }
96
97
    public function getTablePrefix(): string
98
    {
99
        return $this->connection->getTablePrefix();
100
    }
101
102
    public function getTableSchema(string $name, bool $refresh = false): TableSchemaInterface|null
103
    {
104
        return $this->connection->getTableSchema($name, $refresh);
105
    }
106
107
    public function getTransaction(): TransactionInterface|null
108
    {
109
        return $this->connection->getTransaction();
110
    }
111
112
    public function isActive(): bool
113
    {
114
        return $this->connection->isActive();
115
    }
116
117
    public function isSavepointEnabled(): bool
118
    {
119
        return $this->connection->isSavepointEnabled();
120
    }
121
122
    public function noCache(Closure $closure): mixed
123
    {
124
        return $this->connection->noCache($closure);
0 ignored issues
show
Bug introduced by
The method noCache() does not exist on Yiisoft\Db\Connection\ConnectionInterface. It seems like you code against a sub-type of Yiisoft\Db\Connection\ConnectionInterface such as Yiisoft\Yii\Debug\Collec...onnectionInterfaceProxy. ( Ignorable by Annotation )

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

124
        return $this->connection->/** @scrutinizer ignore-call */ noCache($closure);
Loading history...
125
    }
126
127
    public function notProfiler(): void
128
    {
129
        $this->connection->notProfiler();
0 ignored issues
show
Bug introduced by
The method notProfiler() does not exist on Yiisoft\Db\Connection\ConnectionInterface. It seems like you code against a sub-type of Yiisoft\Db\Connection\ConnectionInterface such as Yiisoft\Yii\Debug\Collec...onnectionInterfaceProxy. ( Ignorable by Annotation )

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

129
        $this->connection->/** @scrutinizer ignore-call */ 
130
                           notProfiler();
Loading history...
130
    }
131
132
    public function open(): void
133
    {
134
        $this->connection->open();
135
    }
136
137
    public function queryCacheEnable(bool $value): void
138
    {
139
        $this->connection->queryCacheEnable($value);
0 ignored issues
show
Bug introduced by
The method queryCacheEnable() does not exist on Yiisoft\Db\Connection\ConnectionInterface. It seems like you code against a sub-type of Yiisoft\Db\Connection\ConnectionInterface such as Yiisoft\Yii\Debug\Collec...onnectionInterfaceProxy. ( Ignorable by Annotation )

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

139
        $this->connection->/** @scrutinizer ignore-call */ 
140
                           queryCacheEnable($value);
Loading history...
140
    }
141
142
    public function quoteValue(mixed $value): mixed
143
    {
144
        return $this->connection->quoteValue($value);
145
    }
146
147
    public function setEnableSavepoint(bool $value): void
148
    {
149
        $this->connection->setEnableSavepoint($value);
150
    }
151
152
    public function setTablePrefix(string $value): void
153
    {
154
        $this->connection->setTablePrefix($value);
155
    }
156
157
    public function transaction(Closure $closure, string $isolationLevel = null): mixed
158
    {
159
        return $this->connection->transaction($closure, $isolationLevel);
160
    }
161
162
    public function setProfiler(?ProfilerInterface $profiler): void
163
    {
164
        $this->connection->setProfiler($profiler);
165
    }
166
}
167