RadioStationDeletionApplication   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
c 1
b 0
f 0
dl 0
loc 26
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 19 2
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Uxmp\Core\Api\RadioStation;
6
7
use Psr\Http\Message\ResponseInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
use Uxmp\Core\Api\AbstractApiApplication;
10
use Uxmp\Core\Api\Lib\Message\JsonEnabledResponseInterface;
11
use Uxmp\Core\Orm\Repository\RadioStationRepositoryInterface;
12
13
/**
14
 * Radio station deletion
15
 */
16
final class RadioStationDeletionApplication extends AbstractApiApplication
17
{
18 2
    public function __construct(
19
        private readonly RadioStationRepositoryInterface $radioStationRepository,
20
    ) {
21 2
    }
22
23 2
    protected function run(
24
        ServerRequestInterface $request,
25
        JsonEnabledResponseInterface $response,
26
        array $args
27
    ): ResponseInterface {
28 2
        $stationId = (int) ($args['stationId'] ?? 0);
29
30 2
        $station = $this->radioStationRepository->find($stationId);
31
32 2
        $result = false;
33
34 2
        if ($station !== null) {
35 1
            $this->radioStationRepository->delete($station);
36
37 1
            $result = true;
38
        }
39
40 2
        return $response->withJson([
41 2
            'result' => $result,
42 2
        ]);
43
    }
44
}
45