Passed
Push — master ( 3e13b9...155993 )
by Vladimir
02:26
created

Kernel::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Foundation;
6
7
use FondBot\Channels\Channel;
8
use FondBot\Conversation\Context;
9
use Illuminate\Contracts\Container\Container;
10
use FondBot\Foundation\Commands\TerminateKernel;
11
12
class Kernel
13
{
14
    public const VERSION = '2.0';
15
16
    private $container;
17
18
    /** @var Channel|null */
19
    private $channel;
20
21
    /** @var Context|null */
22
    private $context;
23
24
    public function __construct(Container $container)
25
    {
26
        $this->container = $container;
27
    }
28
29
    /**
30
     * Initialize kernel.
31
     *
32
     * @param Channel $channel
33
     */
34
    public function initialize(Channel $channel): void
35
    {
36
        $this->channel = $channel;
37
38
        TerminateKernel::dispatch();
39
    }
40
41
    /**
42
     * Get current channel.
43
     *
44
     * @return Channel|null
45
     */
46
    public function getChannel(): ?Channel
47
    {
48
        return $this->channel;
49
    }
50
51
    /**
52
     * Get context.
53
     *
54
     * @return Context|null
55
     */
56
    public function getContext(): ?Context
57
    {
58
        return $this->context;
59
    }
60
61
    /**
62
     * Set context.
63
     *
64
     * @param Context $context
65
     */
66
    public function setContext(Context $context): void
67
    {
68
        $this->context = $context;
69
    }
70
}
71