Passed
Push — master ( 98541d...d359a0 )
by
unknown
08:18
created

Session::getChannel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Conversation;
6
7
use FondBot\Drivers\Chat;
8
use FondBot\Drivers\User;
9
use FondBot\Channels\Channel;
10
use FondBot\Contracts\Conversable;
11
use Illuminate\Contracts\Support\Arrayable;
12
13
class Session implements Arrayable
14
{
15
    private $channel;
16
    private $chat;
17
    private $user;
18
    private $intent;
19
    private $interaction;
20
21 7
    public function __construct(
22
        Channel $channel,
23
        Chat $chat,
24
        User $user,
25
        Intent $intent = null,
26
        Interaction $interaction = null
27
    ) {
28 7
        $this->channel = $channel;
29 7
        $this->chat = $chat;
30 7
        $this->user = $user;
31 7
        $this->intent = $intent;
32 7
        $this->interaction = $interaction;
33 7
    }
34
35
    /**
36
     * Get channel name.
37
     *
38
     * @return Channel
39
     */
40 1
    public function getChannel(): Channel
41
    {
42 1
        return $this->channel;
43
    }
44
45
    /**
46
     * Get chat.
47
     *
48
     * @return Chat
49
     */
50 1
    public function getChat(): Chat
51
    {
52 1
        return $this->chat;
53
    }
54
55
    /**
56
     * Get user.
57
     *
58
     * @return User
59
     */
60 1
    public function getUser(): User
61
    {
62 1
        return $this->user;
63
    }
64
65
    /**
66
     * Get current intent.
67
     *
68
     * @return Intent|Conversable|null
69
     */
70 1
    public function getIntent(): ?Intent
71
    {
72 1
        return $this->intent;
73
    }
74
75
    /**
76
     * Set intent.
77
     *
78
     * @param Intent $intent
79
     */
80 1
    public function setIntent(Intent $intent): void
81
    {
82 1
        $this->intent = $intent;
83 1
    }
84
85
    /**
86
     * Get interaction.
87
     *
88
     * @return Interaction|Conversable|null
89
     */
90 1
    public function getInteraction(): ?Interaction
91
    {
92 1
        return $this->interaction;
93
    }
94
95
    /**
96
     * Set interaction.
97
     *
98
     * @param Interaction|null $interaction
99
     */
100 1
    public function setInteraction(?Interaction $interaction): void
101
    {
102 1
        $this->interaction = $interaction;
103 1
    }
104
105
    /**
106
     * Get the instance as an array.
107
     *
108
     * @return array
109
     */
110 1
    public function toArray(): array
111
    {
112
        return [
113 1
            'intent' => $this->intent !== null ? get_class($this->intent) : null,
114 1
            'interaction' => $this->interaction !== null ? get_class($this->interaction) : null,
115
        ];
116
    }
117
}
118