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

h4kuna / critical-cache / 10593293712

28 Aug 2024 08:41AM UTC coverage: 93.365%. First build
10593293712

push

github

h4kuna
feat(Improve): easier API

122 of 133 new or added lines in 11 files covered. (91.73%)

197 of 211 relevant lines covered (93.36%)

0.93 hits per line

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

81.82
/src/PSR16/Pool/CachePoolFactory.php
1
<?php declare(strict_types=1);
2

3
namespace h4kuna\CriticalCache\PSR16\Pool;
4

5
use Beste\Clock\SystemClock;
6
use h4kuna\CriticalCache\Exceptions\MissingDependencyException;
7
use h4kuna\CriticalCache\PSR16\PSR16CacheFactory;
8
use h4kuna\Memoize\PSR16\MemoryCache;
9
use Psr\Clock\ClockInterface;
10
use Psr\SimpleCache\CacheInterface;
11

12
final class CachePoolFactory implements CachePoolFactoryInterface
13
{
14
        private ClockInterface $clock;
15

16
        public function __construct(
1✔
17
                private PSR16CacheFactory $cacheFactory,
18
                ClockInterface $clock = null,
19
        ) {
20
                $this->clock = $clock ?? self::createClock();
1✔
21
        }
1✔
22

23
        private static function createClock(): ClockInterface
24
        {
NEW
25
                MissingDependencyException::checkBesteClock();
×
26

NEW
27
                return SystemClock::create();
×
28
        }
29

30

31
        public function create(string|array $namespace = ''): CacheInterface
1✔
32
        {
33
                return new CachePool(
1✔
34
                        is_array($namespace)
1✔
35
                                ? $namespace
1✔
36
                                : [new MemoryCache(), $this->cacheFactory->create($namespace)],
1✔
37
                        $this->clock,
1✔
38
                );
39
        }
40
}
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