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