• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FluidTYPO3 / flux / 27757675993

18 Jun 2026 11:55AM UTC coverage: 89.162% (-3.5%) from 92.646%
27757675993

push

github

NamelessCoder
[TASK] Address last phpstan warnings

6228 of 6985 relevant lines covered (89.16%)

40.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.0
/Classes/Service/CacheService.php
1
<?php
2
namespace FluidTYPO3\Flux\Service;
3

4
/*
5
 * This file is part of the FluidTYPO3/Flux project under GPLv2 or later.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE.md file that was distributed with this source code.
9
 */
10

11
use Doctrine\DBAL\Exception\TableNotFoundException;
12
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
13
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
14
use TYPO3\CMS\Core\SingletonInterface;
15

16
class CacheService implements SingletonInterface
17
{
18
    private FrontendInterface $persistentCache;
19
    private FrontendInterface $transientCache;
20

21
    public function __construct(FrontendInterface $persistentCache, FrontendInterface $transientCache)
22
    {
23
        $this->persistentCache = $persistentCache;
8✔
24
        $this->transientCache = $transientCache;
8✔
25
    }
26

27
    /**
28
     * @return mixed|false
29
     */
30
    public function getFromCaches(string ...$identifyingValues)
31
    {
32
        $cacheKey = $this->createCacheIdFromValues($identifyingValues);
4✔
33
        try {
34
            $fromTransient = $this->transientCache->get($cacheKey);
4✔
35
            if ($fromTransient) {
4✔
36
                return $fromTransient;
×
37
            }
38

39
            $fromPersistent = $this->persistentCache->get($cacheKey);
4✔
40
            if ($fromPersistent) {
4✔
41
                $this->transientCache->set($cacheKey, $fromPersistent);
4✔
42
                return $fromPersistent;
4✔
43
            }
44
        } catch (NoSuchCacheException | TableNotFoundException $exception) {
×
45
            // Suppressed: operation without cache is allowed.
46
        }
47

48
        return false;
×
49
    }
50

51
    /**
52
     * @param mixed $value
53
     */
54
    public function setInCaches($value, bool $persistent, string ...$identifyingValues): void
55
    {
56
        if ($value === null) {
4✔
57
            $this->remove(...$identifyingValues);
×
58
            return;
×
59
        }
60
        $cacheKey = $this->createCacheIdFromValues($identifyingValues);
4✔
61
        try {
62
            $this->transientCache->set($cacheKey, $value);
4✔
63
            if ($persistent) {
4✔
64
                $this->persistentCache->set($cacheKey, $value);
4✔
65
            }
66
        } catch (NoSuchCacheException | TableNotFoundException $exception) {
×
67
            // Suppressed: operation without cache is allowed.
68
        }
69
    }
70

71
    public function remove(string ...$identifyingValues): void
72
    {
73
        try {
74
            $cacheKey = $this->createCacheIdFromValues($identifyingValues);
×
75
            $this->transientCache->remove($cacheKey);
×
76
            $this->persistentCache->remove($cacheKey);
×
77
        } catch (NoSuchCacheException | TableNotFoundException $exception) {
×
78
            // Suppressed: operation without cache is allowed.
79
        }
80
    }
81

82
    protected function createCacheIdFromValues(array $identifyingValues): string
83
    {
84
        return 'flux-' . md5(serialize($identifyingValues));
8✔
85
    }
86
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc