| Total Complexity | 11 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | abstract class MetadataBaseProvider extends ServiceProvider |
||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @return bool |
||
| 14 | */ |
||
| 15 | protected function getIsCaching() |
||
| 16 | { |
||
| 17 | return true === env('APP_METADATA_CACHING', false); |
||
| 18 | } |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param $isCaching |
||
| 22 | * @param $hasCache |
||
| 23 | * @param $key |
||
| 24 | * @param $meta |
||
| 25 | */ |
||
| 26 | protected function handlePostBoot($isCaching, $hasCache, $key, $meta) |
||
| 27 | { |
||
| 28 | if ($isCaching) { |
||
| 29 | $hasCache = isset($hasCache) ? boolval($hasCache) : false; |
||
| 30 | if (!$hasCache) { |
||
| 31 | $cacheTime = env('APP_METADATA_CACHE_DURATION', null); |
||
| 32 | $cacheTime = !is_numeric($cacheTime) ? 10 : abs($cacheTime); |
||
| 33 | Cache::put($key, $meta, $cacheTime); |
||
| 34 | } |
||
| 35 | } else { |
||
| 36 | Cache::forget($key); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param $classMap |
||
| 42 | * @return array |
||
| 43 | */ |
||
| 44 | protected function getClassMap() |
||
| 45 | { |
||
| 46 | $classes = get_declared_classes(); |
||
| 47 | $autoClass = null; |
||
| 48 | foreach ($classes as $class) { |
||
| 49 | if (\Illuminate\Support\Str::startsWith($class, 'Composer\\Autoload\\ComposerStaticInit')) { |
||
| 50 | $autoClass = $class; |
||
| 51 | } |
||
| 52 | } |
||
| 53 | |||
| 54 | $classes = $autoClass::$classMap; |
||
| 55 | return array_keys($classes); |
||
| 56 | } |
||
| 57 | |||
| 58 | protected function getAppNamespace() |
||
| 66 | } |
||
| 67 | } |
||
| 68 |