| Total Complexity | 14 |
| Total Lines | 61 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | 51 | class Settings extends Collection |
|
| 11 | { |
||
| 12 | 51 | public static function configValues(): array |
|
| 15 | 51 | } |
|
| 16 | |||
| 17 | 51 | public function get($key, $locale = null, $default = null) |
|
| 18 | { |
||
| 19 | 51 | $this->fetch(); |
|
| 20 | 39 | ||
| 21 | if (!isset($this->items[$key])) { |
||
| 22 | return $default; |
||
| 23 | 13 | } |
|
| 24 | 6 | ||
| 25 | 5 | // non-assoc array of items |
|
| 26 | if (is_array($this->items[$key]) && key($this->items[$key]) === 0) { |
||
| 27 | return $this->items[$key]; |
||
| 28 | 6 | } |
|
| 29 | 2 | ||
| 30 | // Array of localized items |
||
| 31 | if (is_array($this->items[$key])) { |
||
| 32 | 6 | if (!$locale) { |
|
| 33 | $locale = app()->getLocale(); |
||
|
|
|||
| 34 | } |
||
| 35 | 7 | ||
| 36 | if ($this->items[$key] == null || !isset($this->items[$key][$locale])) { |
||
| 37 | return $default; |
||
| 38 | 1 | } |
|
| 39 | |||
| 40 | 1 | return $this->items[$key][$locale] ?? $default; |
|
| 41 | 1 | } |
|
| 42 | |||
| 43 | 51 | return $this->items[$key]; |
|
| 44 | } |
||
| 45 | 51 | ||
| 46 | 13 | public function set($key, $value) |
|
| 47 | { |
||
| 48 | $this->items[$key] = $value; |
||
| 49 | 51 | } |
|
| 50 | |||
| 51 | 51 | private function fetch() |
|
| 64 | } |
||
| 65 | |||
| 66 | public function fresh() |
||
| 71 | } |
||
| 72 | } |
||
| 73 |