| Conditions | 4 |
| Paths | 3 |
| Total Lines | 21 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | function settings($key = null, $context = null) |
||
| 16 | { |
||
| 17 | $settings = app(Settings::class); |
||
| 18 | |||
| 19 | // If nothing is passed in to the function, simply return the settings instance. |
||
| 20 | if ($key === null) { |
||
| 21 | return $settings; |
||
| 22 | } |
||
| 23 | |||
| 24 | // We must reset the context to the default value. |
||
| 25 | $settings->setContext([ |
||
| 26 | 'model_type' => null, |
||
| 27 | 'model_id' => null |
||
| 28 | ]); |
||
| 29 | |||
| 30 | // If context is not null, set it. |
||
| 31 | if ($context instanceof Model || is_array($context)) { |
||
| 32 | $settings->setContext($context); |
||
| 33 | } |
||
| 34 | |||
| 35 | return $settings->get(key: $key); |
||
| 36 | } |
||
| 38 |