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