1 | <?php |
||
9 | class ConversationManager |
||
10 | { |
||
11 | /** |
||
12 | * Determine if conversation transitioned. |
||
13 | * |
||
14 | * @var bool |
||
15 | */ |
||
16 | private $transitioned = false; |
||
17 | |||
18 | /** |
||
19 | * Handle received message. |
||
20 | * |
||
21 | * @param ReceivedMessage $message |
||
22 | */ |
||
23 | 2 | public function handle(ReceivedMessage $message): void |
|
42 | |||
43 | /** |
||
44 | * Start conversation. |
||
45 | * |
||
46 | * @param Conversable|mixed $conversable |
||
47 | */ |
||
48 | 5 | public function converse(Conversable $conversable): void |
|
64 | |||
65 | /** |
||
66 | * Transition to intent or interaction. |
||
67 | * |
||
68 | * @param Conversable $conversable |
||
69 | */ |
||
70 | 1 | public function transition(Conversable $conversable): void |
|
75 | |||
76 | /** |
||
77 | * Restart intent or interaction. |
||
78 | * |
||
79 | * @param Conversable|mixed $conversable |
||
80 | */ |
||
81 | 2 | public function restart(Conversable $conversable): void |
|
101 | |||
102 | /** |
||
103 | * Find matching intent. |
||
104 | * |
||
105 | * @param ReceivedMessage $message |
||
106 | * |
||
107 | * @return Intent|null |
||
108 | */ |
||
109 | 1 | private function findIntent(ReceivedMessage $message): Intent |
|
116 | |||
117 | /** |
||
118 | * Determine if conversation started. |
||
119 | * |
||
120 | * @return bool |
||
121 | */ |
||
122 | 2 | private function isInConversation(): bool |
|
126 | } |
||
127 |
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: