1 | <?php |
||
11 | class Context |
||
12 | { |
||
13 | private $channel; |
||
14 | private $chat; |
||
15 | private $user; |
||
16 | private $message; |
||
17 | private $intent; |
||
18 | private $interaction; |
||
19 | private $values; |
||
20 | |||
21 | 9 | public function __construct( |
|
22 | string $channel, |
||
23 | Chat $chat, |
||
24 | User $user, |
||
25 | ReceivedMessage $message, |
||
26 | Intent $intent = null, |
||
27 | Interaction $interaction = null, |
||
28 | array $values = [] |
||
29 | ) { |
||
30 | 9 | $this->channel = $channel; |
|
31 | 9 | $this->chat = $chat; |
|
32 | 9 | $this->user = $user; |
|
33 | 9 | $this->message = $message; |
|
34 | 9 | $this->intent = $intent; |
|
35 | 9 | $this->interaction = $interaction; |
|
36 | 9 | $this->values = $values; |
|
37 | 9 | } |
|
38 | |||
39 | /** |
||
40 | * Get channel name. |
||
41 | * |
||
42 | * @return string |
||
43 | */ |
||
44 | 1 | public function getChannel(): string |
|
48 | |||
49 | /** |
||
50 | * Get chat. |
||
51 | * |
||
52 | * @return Chat |
||
53 | */ |
||
54 | 1 | public function getChat(): Chat |
|
58 | |||
59 | /** |
||
60 | * Get user. |
||
61 | * |
||
62 | * @return User |
||
63 | */ |
||
64 | 1 | public function getUser(): User |
|
68 | |||
69 | /** |
||
70 | * Get message received from user. |
||
71 | * |
||
72 | * @return ReceivedMessage |
||
73 | */ |
||
74 | 1 | public function getMessage(): ReceivedMessage |
|
78 | |||
79 | /** |
||
80 | * Get current intent instance. |
||
81 | * |
||
82 | * @return Intent|Conversable|null |
||
83 | */ |
||
84 | 1 | public function getIntent(): ?Intent |
|
88 | |||
89 | /** |
||
90 | * Set intent instance. |
||
91 | * |
||
92 | * @param Intent $intent |
||
93 | */ |
||
94 | 1 | public function setIntent(Intent $intent): void |
|
98 | |||
99 | /** |
||
100 | * Get current interaction instance. |
||
101 | * |
||
102 | * @return Interaction|Conversable|null |
||
103 | */ |
||
104 | 1 | public function getInteraction(): ?Interaction |
|
108 | |||
109 | /** |
||
110 | * Set interaction instance. |
||
111 | * |
||
112 | * @param Interaction|null $interaction |
||
113 | */ |
||
114 | 1 | public function setInteraction(?Interaction $interaction): void |
|
118 | |||
119 | /** |
||
120 | * Get stored values. |
||
121 | * |
||
122 | * @return array |
||
123 | */ |
||
124 | 1 | public function getValues(): array |
|
128 | |||
129 | /** |
||
130 | * Set values to be stored. |
||
131 | * |
||
132 | * @param array $values |
||
133 | */ |
||
134 | 1 | public function setValues(array $values): void |
|
138 | |||
139 | /** |
||
140 | * Store value. |
||
141 | * |
||
142 | * @param string $key |
||
143 | * @param mixed $value |
||
144 | */ |
||
145 | 1 | public function setValue(string $key, $value): void |
|
149 | |||
150 | /** |
||
151 | * Get the instance as an array. |
||
152 | * |
||
153 | * @return array |
||
154 | */ |
||
155 | 1 | public function toArray(): array |
|
163 | } |
||
164 |