| Conditions | 1 |
| Paths | 1 |
| Total Lines | 15 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| Changes | 5 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 20 | public function create(ChatControl $chatControl): Form |
||
| 21 | { |
||
| 22 | $form = new Form(); |
||
| 23 | $form->setTranslator($this->translator); |
||
| 24 | $form->addText("message", "") |
||
| 25 | ->setRequired("chat.newMessageForm.messageField.empty"); |
||
| 26 | $form->addSubmit("send", "chat.newMessageForm.submitButton.label"); |
||
| 27 | $form->addComponent($chatControl, "chat"); |
||
| 28 | // @phpstan-ignore assign.propertyType |
||
| 29 | $form->onSuccess[] = function (Form $form, array $values): void { |
||
| 30 | /** @var ChatControl $chat */ |
||
| 31 | $chat = $form->getComponent("chat"); |
||
| 32 | $chat->newMessage($values["message"]); |
||
| 33 | }; |
||
| 34 | return $form; |
||
| 35 | } |
||
| 37 |