fondbot /
framework
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | if (!function_exists('kernel')) { |
||
| 6 | /** |
||
| 7 | * Get kernel instance. |
||
| 8 | * |
||
| 9 | * @return \FondBot\FondBot |
||
| 10 | */ |
||
| 11 | function kernel() |
||
| 12 | { |
||
| 13 | return resolve(FondBot\FondBot::class); |
||
| 14 | } |
||
| 15 | 1 | } |
|
| 16 | |||
| 17 | if (!function_exists('context')) { |
||
| 18 | /** |
||
| 19 | * Get context. |
||
| 20 | * |
||
| 21 | * @param string|null $key |
||
| 22 | * |
||
| 23 | * @param mixed|null $default |
||
| 24 | * |
||
| 25 | * @return \FondBot\Conversation\Context|mixed |
||
| 26 | */ |
||
| 27 | function context(string $key = null, $default = null) |
||
|
0 ignored issues
–
show
|
|||
| 28 | { |
||
| 29 | $conversation = resolve(\FondBot\Conversation\ConversationManager::class); |
||
| 30 | |||
| 31 | $context = $conversation->getContext(); |
||
| 32 | 15 | ||
| 33 | if ($key === null) { |
||
| 34 | 15 | return $context; |
|
| 35 | } |
||
| 36 | 15 | ||
| 37 | 15 | return optional($context)->getItem($key, $default); |
|
| 38 | } |
||
| 39 | } |
||
| 40 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.