| Conditions | 2 |
| Paths | 2 |
| Total Lines | 25 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 29 | 2 | protected function run( |
|
| 30 | ServerRequestInterface $request, |
||
| 31 | JsonEnabledResponseInterface $response, |
||
| 32 | array $args |
||
| 33 | ): ResponseInterface { |
||
| 34 | 2 | $stationId = (int) ($args['stationId'] ?? 0); |
|
| 35 | |||
| 36 | 2 | $station = $this->radioStationRepository->find($stationId); |
|
| 37 | 2 | if ($station === null) { |
|
| 38 | 1 | return $response->withStatus(Http::NOT_FOUND); |
|
| 39 | } |
||
| 40 | |||
| 41 | 1 | $body = $this->schemaValidator->getValidatedBody( |
|
| 42 | 1 | $request, |
|
| 43 | 1 | 'RadioStationCreation.json', |
|
| 44 | 1 | ); |
|
| 45 | |||
| 46 | 1 | $station |
|
| 47 | 1 | ->setUrl($body['url']) |
|
| 48 | 1 | ->setName($body['name']); |
|
| 49 | |||
| 50 | 1 | $this->radioStationRepository->save($station); |
|
| 51 | |||
| 52 | 1 | return $response->withJson([ |
|
| 53 | 1 | 'result' => true, |
|
| 54 | 1 | ]); |
|
| 57 |