RedisCache   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 10
c 1
b 0
f 1
dl 0
loc 35
ccs 0
cts 10
cp 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A doContains() 0 7 1
A doFetch() 0 11 2
1
<?php declare(strict_types = 1);
2
3
namespace Portiny\Doctrine\Cache;
4
5
use Doctrine\Common\Cache\RedisCache as DoctrineRedisCache;
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Cache\RedisCache was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
final class RedisCache extends DoctrineRedisCache
8
{
9
	/**
10
	 * @var string[]
11
	 */
12
	private $prefetchCache = [];
13
14
15
	/**
16
	 * {@inheritdoc}
17
	 */
18
	protected function doContains($id): bool
19
	{
20
		// preload value into local variable becase Doctrine need it if TRUE is returned
21
		$value = $this->doFetch($id);
22
		$this->prefetchCache[$id] = $value;
23
24
		return $value !== false;
25
	}
26
27
28
	/**
29
	 * {@inheritdoc}
30
	 */
31
	protected function doFetch($id)
32
	{
33
		// try load value from prefetch cache
34
		$doFetch = $this->prefetchCache[$id] ?? null;
35
		$this->prefetchCache = [];
36
37
		if ($doFetch === null) {
38
			$doFetch = parent::doFetch($id);
39
		}
40
41
		return $doFetch;
42
	}
43
44
}
45