kernel()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
c 2
b 0
f 1
cc 1
nc 1
nop 0
crap 2
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
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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