Conditions | 5 |
Paths | 4 |
Total Lines | 28 |
Code Lines | 16 |
Lines | 8 |
Ratio | 28.57 % |
Tests | 17 |
CRAP Score | 5 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
40 | 4 | public function handle() |
|
41 | { |
||
42 | 4 | $this->comment('Caching all settings'); |
|
43 | 4 | $settings = Settings::all(); |
|
44 | 4 | $duration = config('settings.cache_duration'); |
|
45 | |||
46 | 4 | foreach ($settings as $key => $value) { |
|
47 | 2 | $cache_key = Settings::cacheKey($key); |
|
48 | |||
49 | 2 | Cache::put($cache_key, $value, $duration); |
|
50 | } |
||
51 | |||
52 | 4 | $model = $this->option('model'); |
|
53 | |||
54 | 4 | if (isset($model)) { |
|
55 | 2 | $users = (new $model)->all(); |
|
56 | 2 | View Code Duplication | foreach ($users as $user) { |
57 | 2 | $settings = $user->allSettings(); |
|
58 | 2 | foreach ($settings as $key => $value) { |
|
59 | 2 | $cache_key = $user->settingsCacheKey($key); |
|
60 | |||
61 | 2 | Cache::put($cache_key, $value, $duration); |
|
62 | } |
||
63 | } |
||
64 | } |
||
65 | |||
66 | 4 | $this->info('Cached all settings'); |
|
67 | 4 | } |
|
68 | } |
||
69 |
Adding a
@return
annotation 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.