Total Complexity | 3 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Coverage | 70% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | trait CachesBindings |
||
11 | { |
||
12 | /** |
||
13 | * Get the clue to access the cache. |
||
14 | * |
||
15 | * @return string |
||
16 | */ |
||
17 | 16 | public function cacheClue(): string |
|
18 | { |
||
19 | 16 | return static::CACHE_KEY . $this->classFolder; |
|
|
|||
20 | } |
||
21 | |||
22 | /** |
||
23 | * Cache the binding. |
||
24 | * |
||
25 | * @param string $interface |
||
26 | * @param \Closure|string $concrete |
||
27 | * |
||
28 | * @return void |
||
29 | * @throws ContainerExceptionInterface |
||
30 | * @throws NotFoundExceptionInterface |
||
31 | */ |
||
32 | 15 | protected function cacheBindingFor(string $interface, \Closure|string $concrete): void |
|
33 | { |
||
34 | 15 | $clue = $this->cacheClue(); |
|
35 | |||
36 | 15 | $cache = cache()->get($clue); |
|
37 | |||
38 | 15 | $cache[$interface] = $concrete; |
|
39 | |||
40 | 15 | cache()->put($clue, $cache); |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * Apply the caching. |
||
45 | * |
||
46 | * @return void |
||
47 | * @throws ContainerExceptionInterface |
||
48 | * @throws NotFoundExceptionInterface |
||
49 | */ |
||
50 | protected function applyCache(): void |
||
54 | ); |
||
55 | } |
||
56 | } |
||
57 |