| Total Complexity | 6 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 16 | abstract class MetadataBaseProvider extends ServiceProvider |
||
| 17 | { |
||
| 18 | /** @var Application */ |
||
| 19 | protected $app; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @return bool |
||
| 23 | */ |
||
| 24 | protected function getIsCaching() |
||
| 25 | { |
||
| 26 | return true === env('APP_METADATA_CACHING', false); |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @param bool $isCaching |
||
| 31 | * @param bool|null $hasCache |
||
| 32 | * @param string $key |
||
| 33 | * @param mixed $meta |
||
| 34 | */ |
||
| 35 | protected function handlePostBoot(bool $isCaching, ?bool $hasCache, string $key, $meta): void |
||
| 36 | { |
||
| 37 | if (!$isCaching) { |
||
| 38 | Cache::forget($key); |
||
| 39 | return; |
||
| 40 | } |
||
| 41 | $hasCache = isset($hasCache) ? boolval($hasCache) : false; |
||
| 42 | if (!$hasCache) { |
||
| 43 | $cacheTime = abs(intval(env('APP_METADATA_CACHE_DURATION', 10))); |
||
| 44 | $cacheTime = max($cacheTime, 1); |
||
| 45 | Cache::put($key, $meta, $cacheTime); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @return string |
||
| 51 | */ |
||
| 52 | protected function getAppNamespace(): string |
||
| 55 | } |
||
| 56 | } |
||
| 57 |