| Conditions | 8 |
| Paths | 7 |
| Total Lines | 27 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 8 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | 52 | public function get($key, $locale = null, $default = null) |
|
| 18 | { |
||
| 19 | 52 | $this->fetch(); |
|
| 20 | |||
| 21 | 52 | if (!isset($this->items[$key])) { |
|
| 22 | 40 | return $default; |
|
| 23 | } |
||
| 24 | |||
| 25 | 13 | // non-assoc array of items |
|
| 26 | 6 | if (is_array($this->items[$key]) && key($this->items[$key]) === 0) { |
|
| 27 | 5 | return $this->items[$key]; |
|
| 28 | } |
||
| 29 | |||
| 30 | 6 | // Array of localized items |
|
| 31 | 2 | if (is_array($this->items[$key])) { |
|
| 32 | if (!$locale) { |
||
| 33 | $locale = app()->getLocale(); |
||
|
|
|||
| 34 | 6 | } |
|
| 35 | |||
| 36 | if ($this->items[$key] == null || !isset($this->items[$key][$locale])) { |
||
| 37 | 7 | return $default; |
|
| 38 | } |
||
| 39 | |||
| 40 | 1 | return $this->items[$key][$locale] ?? $default; |
|
| 41 | } |
||
| 42 | 1 | ||
| 43 | 1 | return $this->items[$key]; |
|
| 44 | } |
||
| 73 |