Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ConfigUpdate
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
1 / 1
3
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\Config as Query;
13use BO\Zmsapi\Helper\User;
14
15class ConfigUpdate extends BaseController
16{
17    /**
18     * @SuppressWarnings(Param)
19     * @return String
20     */
21    public function readResponse(
22        \Psr\Http\Message\RequestInterface $request,
23        \Psr\Http\Message\ResponseInterface $response,
24        array $args
25    ) {
26        try {
27            (new Helper\User($request))->checkRights('superuser');
28        } catch (\Exception $exception) {
29            $token = $request->getHeader('X-Token');
30            if (\App::SECURE_TOKEN != current($token)) {
31                throw new Exception\Config\ConfigAuthentificationFailed();
32            }
33        }
34        $input = Validator::input()->isJson()->assertValid()->getValue();
35        $entity = new \BO\Zmsentities\Config($input);
36        $entity->testValid();
37        $entity = (new Query())->updateEntity($entity);
38
39        $message = Response\Message::create($request);
40        $message->data = $entity;
41
42        $response = Render::withLastModified($response, time(), '0');
43        $response = Render::withJson($response, $message, $message->getStatuscode());
44        return $response;
45    }
46}