1 | <?php |
||
11 | class ConversationManager |
||
12 | { |
||
13 | /** |
||
14 | * Determine if conversation transitioned. |
||
15 | * |
||
16 | * @var bool |
||
17 | */ |
||
18 | private $transitioned = false; |
||
19 | |||
20 | private $kernel; |
||
21 | |||
22 | 6 | public function __construct(Kernel $kernel) |
|
26 | |||
27 | /** |
||
28 | * Handle received message. |
||
29 | * |
||
30 | * @param ReceivedMessage $message |
||
31 | */ |
||
32 | 2 | public function handle(ReceivedMessage $message): void |
|
55 | |||
56 | /** |
||
57 | * Start conversation. |
||
58 | * |
||
59 | * @param Conversable|mixed $conversable |
||
60 | */ |
||
61 | 5 | public function converse(Conversable $conversable): void |
|
77 | |||
78 | /** |
||
79 | * Transition to intent or interaction. |
||
80 | * |
||
81 | * @param Conversable $conversable |
||
82 | */ |
||
83 | 1 | public function transition(Conversable $conversable): void |
|
88 | |||
89 | /** |
||
90 | * Restart intent or interaction. |
||
91 | * |
||
92 | * @param Conversable|mixed $conversable |
||
93 | */ |
||
94 | 2 | public function restart(Conversable $conversable): void |
|
114 | |||
115 | /** |
||
116 | * Find matching intent. |
||
117 | * |
||
118 | * @param ReceivedMessage $message |
||
119 | * |
||
120 | * @return Intent|null |
||
121 | */ |
||
122 | 1 | private function findIntent(ReceivedMessage $message): Intent |
|
129 | |||
130 | /** |
||
131 | * Determine if conversation started. |
||
132 | * |
||
133 | * @return bool |
||
134 | */ |
||
135 | 2 | private function isInConversation(): bool |
|
139 | } |
||
140 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: