Passed
Push — master ( e99f69...f96aae )
by Vladimir
02:27
created

helpers.php ➔ kernel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
use FondBot\Contracts\Conversation\Manager;
6
7
if (!function_exists('kernel')) {
8
    /**
9
     * Get kernel instance.
10
     *
11
     * @return FondBot\Foundation\Kernel
12
     */
13
    function kernel()
14
    {
15 1
        return resolve(FondBot\Foundation\Kernel::class);
16
    }
17
}
18
19
if (!function_exists('context')) {
20
    /**
21
     * Get context.
22
     *
23
     * @param string|null $key
24
     *
25
     * @param mixed|null  $default
26
     *
27
     * @return \FondBot\Conversation\Context|mixed
28
     */
29
    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...
30
    {
31
        /** @var Manager $conversation */
32 15
        $conversation = resolve(Manager::class);
33
34 15
        $context = $conversation->getContext();
35
36 15
        if ($key === null) {
37 15
            return $context;
38
        }
39
40 3
        return optional($context)->getItem($key, $default);
41
    }
42
}
43