ResourceStorageSaver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 15
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 12 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\QueryRepository;
6
7
use Psr\Cache\CacheItemPoolInterface;
8
use Symfony\Component\Cache\CacheItem;
9
10
use function assert;
11
12
final class ResourceStorageSaver
13
{
14
    /** @param list<string> $tags */
0 ignored issues
show
Bug introduced by
The type BEAR\QueryRepository\list 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...
15
    public function __invoke(string $key, mixed $value, CacheItemPoolInterface $pool, array $tags, int|null $ttl): bool
16
    {
17
        $cacheItem = $pool->getItem($key);
18
        $cacheItem->set($value);
19
        assert($cacheItem instanceof CacheItem);
20
        $cacheItem->tag($tags);
21
22
        if ($ttl !== null && $ttl > 0) {
23
            $cacheItem->expiresAfter($ttl);
24
        }
25
26
        return $pool->save($cacheItem);
27
    }
28
}
29