| Total Complexity | 7 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | trait TestTrait |
||
| 16 | { |
||
| 17 | private CacheInterface|null $cache = null; |
||
| 18 | private QueryCache|null $queryCache = null; |
||
| 19 | private SchemaCache|null $schemaCache = null; |
||
| 20 | |||
| 21 | protected function getConnection(string $dsn = 'sqlite::memory:'): ConnectionPDOInterface |
||
| 22 | { |
||
| 23 | return new Stub\Connection(new PDODriver($dsn), $this->getQueryCache(), $this->getSchemaCache()); |
||
| 24 | } |
||
| 25 | |||
| 26 | private function getCache(): CacheInterface |
||
| 27 | { |
||
| 28 | if ($this->cache === null) { |
||
| 29 | $this->cache = new Cache(new ArrayCache()); |
||
| 30 | } |
||
| 31 | |||
| 32 | return $this->cache; |
||
|
|
|||
| 33 | } |
||
| 34 | |||
| 35 | private function getQueryCache(): QueryCache |
||
| 36 | { |
||
| 37 | if ($this->queryCache === null) { |
||
| 38 | $this->queryCache = new QueryCache($this->getCache()); |
||
| 39 | } |
||
| 40 | |||
| 41 | return $this->queryCache; |
||
| 42 | } |
||
| 43 | |||
| 44 | private function getSchemaCache(): SchemaCache |
||
| 51 | } |
||
| 52 | } |
||
| 53 |