| Total Complexity | 3 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Coverage | 70% |
| Changes | 3 | ||
| 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 |
|
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Use the bindings from the cache. |
||
| 24 | * |
||
| 25 | * @return void |
||
| 26 | * @throws ContainerExceptionInterface |
||
| 27 | * @throws NotFoundExceptionInterface |
||
| 28 | */ |
||
| 29 | protected function fromCache(): void |
||
| 30 | { |
||
| 31 | collect(cache()->get($this->cacheClue()))->each( |
||
| 32 | fn ($concrete, $interface) => app()->{$this->bindingType}($interface, $concrete) |
||
| 33 | ); |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Cache the binding. |
||
| 38 | * |
||
| 39 | * @param string $interface |
||
| 40 | * @param \Closure|string $concrete |
||
| 41 | * |
||
| 42 | * @return void |
||
| 43 | * @throws ContainerExceptionInterface |
||
| 44 | * @throws NotFoundExceptionInterface |
||
| 45 | */ |
||
| 46 | 15 | protected function cacheBindingFor(string $interface, \Closure|string $concrete): void |
|
| 55 | } |
||
| 56 | } |
||
| 57 |