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