Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| NullCache | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| get | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| set | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\ResourceLoader\Cache; |
| 6 | |
| 7 | use Phpdftk\ResourceLoader\FetchResult; |
| 8 | |
| 9 | /** |
| 10 | * No-op cache backend. Every `get()` returns null (cache miss) and |
| 11 | * every `set()` discards the result. |
| 12 | * |
| 13 | * Default when callers don't supply a cache explicitly — keeps the |
| 14 | * loader stateless and side-effect-free. Use a real backend |
| 15 | * (`FileCache`, `MemoryCache`) when fetching the same URL twice in |
| 16 | * one render is plausible. |
| 17 | */ |
| 18 | final class NullCache implements CacheInterface |
| 19 | { |
| 20 | public function get(string $key): ?FetchResult |
| 21 | { |
| 22 | unset($key); |
| 23 | return null; |
| 24 | } |
| 25 | |
| 26 | public function set(string $key, FetchResult $result): void |
| 27 | { |
| 28 | unset($key, $result); |
| 29 | } |
| 30 | } |