Passed
Pull Request — master (#380)
by Wilmer
13:00 queued 10:01
created

TestTrait   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 50
rs 10
c 2
b 0
f 0
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getSchemaCache() 0 3 1
A getConnection() 0 3 1
A getQuoter() 0 3 1
A getConnectionWithData() 0 3 1
A getProfiler() 0 3 1
A getCache() 0 3 1
A getQueryCache() 0 3 1
A getConnectionWithDsn() 0 3 1
A getLogger() 0 3 1
A getQuery() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Tests\Support;
6
7
use Psr\Log\LoggerInterface;
8
use Yiisoft\Cache\CacheInterface;
9
use Yiisoft\Db\Cache\QueryCache;
10
use Yiisoft\Db\Cache\SchemaCache;
11
use Yiisoft\Db\Driver\PDO\ConnectionPDOInterface;
12
use Yiisoft\Db\Query\Query;
13
use Yiisoft\Db\Schema\Quoter;
14
use Yiisoft\Db\Schema\QuoterInterface;
15
use Yiisoft\Profiler\ProfilerInterface;
16
17
trait TestTrait
18
{
19
    protected function getConnection(): ConnectionPDOInterface
20
    {
21
        return Mock::getConnection();
22
    }
23
24
    protected function getConnectionWithData(): ConnectionPDOInterface
25
    {
26
        return  Mock::getConnection(true);
27
    }
28
29
    protected function getConnectionWithDsn(string $dsn): ConnectionPDOInterface
30
    {
31
        return Mock::getConnection(false, $dsn);
32
    }
33
34
    protected function getCache(): CacheInterface
35
    {
36
        return Mock::getCache();
37
    }
38
39
    protected function getQuery(ConnectionPDOInterface $db): Query
40
    {
41
        return new Query($db);
42
    }
43
44
    protected function getQuoter(): QuoterInterface
45
    {
46
        return new Quoter('`', '`', '');
47
    }
48
49
    protected function getLogger(): LoggerInterface
50
    {
51
        return  Mock::getLogger();
52
    }
53
54
    protected function getQueryCache(): QueryCache
55
    {
56
        return  Mock::getQueryCache();
57
    }
58
59
    protected function getSchemaCache(): SchemaCache
60
    {
61
        return  Mock::getSchemaCache();
62
    }
63
64
    protected function getProfiler(): ProfilerInterface
65
    {
66
        return  Mock::getProfiler();
67
    }
68
}
69