| Conditions | 2 |
| Paths | 2 |
| Total Lines | 25 |
| Code Lines | 13 |
| Lines | 9 |
| Ratio | 36 % |
| Tests | 16 |
| CRAP Score | 2 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 40 | 4 | public function handle() |
|
| 41 | { |
||
| 42 | 4 | $this->comment('Caching all settings'); |
|
| 43 | 4 | $duration = config('settings.cache_duration'); |
|
| 44 | |||
| 45 | 4 | Settings::all()->each(function ($value, $key) use ($duration) { |
|
| 46 | 2 | $cache_key = Settings::cacheKey($key); |
|
| 47 | |||
| 48 | 2 | Cache::put($cache_key, $value, $duration); |
|
| 49 | 4 | }); |
|
| 50 | |||
| 51 | 4 | $model = $this->option('model'); |
|
| 52 | |||
| 53 | 4 | View Code Duplication | if (isset($model)) { |
| 54 | (new $model)->all()->each(function ($user) use ($duration) { |
||
| 55 | 2 | $user->allSettings()->each(function ($value, $key) use ($user, $duration) { |
|
| 56 | 2 | $cache_key = $user->settingsCacheKey($key); |
|
| 57 | |||
| 58 | 2 | Cache::put($cache_key, $value, $duration); |
|
| 59 | 2 | }); |
|
| 60 | 2 | }); |
|
| 61 | } |
||
| 62 | |||
| 63 | 4 | $this->info('Cached all settings'); |
|
| 64 | 4 | } |
|
| 65 | } |
||
| 66 |
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.