| Conditions | 2 |
| Paths | 2 |
| Total Lines | 11 |
| Code Lines | 6 |
| Lines | 11 |
| Ratio | 100 % |
| Tests | 7 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 21 | 8 | View Code Duplication | public function getSettings($key, $default = null) |
| 22 | { |
||
| 23 | 8 | $cache_key = config('settings.cache_prefix') . $key . '-' . $this->id; |
|
| 24 | 8 | $duration = config('settings.cache_duration'); |
|
| 25 | |||
| 26 | 8 | $value = Cache::remember($cache_key, $duration, function () use ($key) { |
|
| 27 | 6 | return Setting::where('key', $key)->where('owner_id', $this->id)->pluck('value')->first(); |
|
| 28 | 8 | }); |
|
| 29 | |||
| 30 | 8 | return $value ? $value : $default; |
|
| 31 | } |
||
| 32 | |||
| 45 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: