Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
11 / 11 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| TicketController | |
100.00% |
11 / 11 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| respond | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| invoicepdf | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| invoicesend | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | use Psr\Http\Message\ResponseInterface as Response; |
| 6 | use Psr\Http\Message\ServerRequestInterface as Request; |
| 7 | use UppServices\TicketService; |
| 8 | |
| 9 | /** |
| 10 | * Slim controller for staff ticket invoice PDF and email endpoints. |
| 11 | * Delegates to TicketService. |
| 12 | */ |
| 13 | class TicketController |
| 14 | { |
| 15 | private readonly TicketService $ticketService; |
| 16 | |
| 17 | public function __construct(TicketService $ticketService) |
| 18 | { |
| 19 | $this->ticketService = $ticketService; |
| 20 | } |
| 21 | |
| 22 | private function respond(Response $response, array $result): Response |
| 23 | { |
| 24 | $response->getBody()->write($result['output']); |
| 25 | return $response->withHeader('Content-Type', $result['contentType']); |
| 26 | } |
| 27 | |
| 28 | /** POST /ticket/invoicepdf - render invoice PDF from client HTML */ |
| 29 | public function invoicepdf(Request $request, Response $response): Response |
| 30 | { |
| 31 | return $this->respond($response, $this->ticketService->invoicepdf( |
| 32 | (string) $request->getBody(), |
| 33 | $request->getQueryParams() |
| 34 | )); |
| 35 | } |
| 36 | |
| 37 | /** POST /ticket/invoicesend - email invoice PDF to recipient */ |
| 38 | public function invoicesend(Request $request, Response $response): Response |
| 39 | { |
| 40 | return $this->respond($response, $this->ticketService->invoicesend( |
| 41 | (string) $request->getBody(), |
| 42 | $request->getQueryParams() |
| 43 | )); |
| 44 | } |
| 45 | } |