Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
OrganisationHash
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3/**
4 * @package ZMS API
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsapi;
9
10use BO\Slim\Render;
11use BO\Mellon\Validator;
12use BO\Zmsdb\Ticketprinter as Ticketprinter;
13use BO\Zmsdb\Organisation as Query;
14
15class OrganisationHash extends BaseController
16{
17    /**
18     * @SuppressWarnings(Param)
19     * @return \Psr\Http\Message\ResponseInterface
20     */
21    #[\Override]
22    public function readResponse(
23        \Psr\Http\Message\RequestInterface $request,
24        \Psr\Http\Message\ResponseInterface $response,
25        array $args
26    ) {
27        \BO\Zmsdb\Connection\Select::getWriteConnection();
28        $organisation = (new Query())->readEntity($args['id']);
29        if (! $organisation) {
30            throw new Exception\Organisation\OrganisationNotFound();
31        }
32        //$ticketprinterName = Validator::param('name')->isString()->setDefault('')->getValue();
33        $ticketprinterName = "Ticket Printer for " . $organisation->name;
34        $ticketprinter = (new Ticketprinter())->writeEntityWithHash($organisation->id, $ticketprinterName);
35
36        $message = Response\Message::create($request);
37        $message->data = $ticketprinter;
38
39        $response = Render::withLastModified($response, time(), '0');
40        $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode());
41        return $response;
42    }
43}