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

tempestphp / tempest-framework / 11319238494

13 Oct 2024 12:13PM UTC coverage: 82.008% (-0.09%) from 82.1%
11319238494

push

github

web-flow
fix: view argument casing (#585)

4 of 4 new or added lines in 1 file covered. (100.0%)

30 existing lines in 5 files now uncovered.

6764 of 8248 relevant lines covered (82.01%)

39.93 hits per line

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

88.89
/src/Tempest/Cache/src/IsCache.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Cache;
6

7
use Closure;
8
use DateTimeInterface;
9
use Psr\Cache\CacheItemInterface;
10
use Psr\Cache\CacheItemPoolInterface;
11

12
trait IsCache
13
{
14
    abstract protected function getCachePool(): CacheItemPoolInterface;
15

16
    public function put(string $key, mixed $value, ?DateTimeInterface $expiresAt = null): CacheItemInterface
9✔
17
    {
18
        $item = $this->getCachePool()
9✔
19
            ->getItem($key)
9✔
20
            ->set($value);
9✔
21

22
        if ($expiresAt !== null) {
9✔
23
            $item = $item->expiresAt($expiresAt);
3✔
24
        }
25

26
        if ($this->isEnabled()) {
9✔
27
            $this->getCachePool()->save($item);
8✔
28
        }
29

30
        return $item;
9✔
31
    }
32

33
    public function get(string $key): mixed
282✔
34
    {
35
        if (! $this->isEnabled()) {
282✔
36
            return null;
1✔
37
        }
38

39
        return $this->getCachePool()->getItem($key)->get();
281✔
40
    }
41

42
    /** @param Closure(): mixed $cache */
43
    public function resolve(string $key, Closure $cache, ?DateTimeInterface $expiresAt = null): mixed
1✔
44
    {
45
        if (! $this->isEnabled()) {
1✔
UNCOV
46
            return $cache();
×
47
        }
48

49
        $item = $this->getCachePool()->getItem($key);
1✔
50

51
        if (! $item->isHit()) {
1✔
52
            $item = $this->put($key, $cache(), $expiresAt);
1✔
53
        }
54

55
        return $item->get();
1✔
56
    }
57

58
    public function remove(string $key): void
1✔
59
    {
60
        if (! $this->isEnabled()) {
1✔
UNCOV
61
            return;
×
62
        }
63

64
        $this->getCachePool()->deleteItem($key);
1✔
65
    }
66

67
    public function clear(): void
49✔
68
    {
69
        if (! $this->getCachePool()->clear()) {
49✔
UNCOV
70
            throw new CouldNotClearCache();
×
71
        }
72
    }
73
}
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