| Conditions | 4 |
| Paths | 2 |
| Total Lines | 34 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 17 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | 6 | public function contact( |
|
| 28 | ContactForm $form, |
||
| 29 | Flash $flash, |
||
| 30 | ContactMailer $mailer, |
||
| 31 | UrlGeneratorInterface $url, |
||
| 32 | ServerRequestInterface $request |
||
| 33 | ): ResponseInterface { |
||
| 34 | 6 | $body = $request->getParsedBody(); |
|
| 35 | 6 | $method = $request->getMethod(); |
|
| 36 | |||
| 37 | 6 | if (($method === Method::POST) && $form->load($body) && $form->validate()) { |
|
|
|
|||
| 38 | 2 | $mailer->send($form, $request); |
|
| 39 | |||
| 40 | 2 | $flash->add( |
|
| 41 | 2 | 'is-success', |
|
| 42 | [ |
||
| 43 | 2 | 'header' => 'System mailer notification.', |
|
| 44 | 'body' => 'Thanks to contact us, we\'ll get in touch with you as soon as possible.' |
||
| 45 | ], |
||
| 46 | 2 | true |
|
| 47 | ); |
||
| 48 | |||
| 49 | 2 | return $this->responseFactory |
|
| 50 | 2 | ->createResponse(302) |
|
| 51 | 2 | ->withHeader( |
|
| 52 | 2 | Header::LOCATION, |
|
| 53 | 2 | $url->generate('contact/form') |
|
| 54 | ); |
||
| 55 | } |
||
| 56 | |||
| 57 | 6 | return $this->viewRenderer->withCsrf()->render( |
|
| 58 | 6 | 'form', |
|
| 59 | [ |
||
| 60 | 6 | 'form' => $form |
|
| 61 | ] |
||
| 65 |