Passed
Push — master ( 48bfaa...170129 )
by Nico
25:44
created

DeleteColonyScan   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 13 3
A __construct() 0 3 1
A performSessionCheck() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Database\Action;
6
7
use request;
8
use Stu\Module\Control\ActionControllerInterface;
9
use Stu\Module\Control\GameControllerInterface;
10
use Stu\Orm\Repository\ColonyScanRepositoryInterface;
11
use Stu\Module\Ship\View\Noop\Noop;
12
13
final class DeleteColonyScan implements ActionControllerInterface
14
{
15
    public const ACTION_IDENTIFIER = 'B_DELETE_COLONY_SCAN';
16
17
    public function __construct(
18
        private ColonyScanRepositoryInterface $colonyScanRepository
19
    ) {
20
    }
21
22
    public function handle(GameControllerInterface $game): void
23
    {
24
        $colonyScan = $this->colonyScanRepository->find(request::getIntFatal('id'));
25
26
        if (
27
            $colonyScan === null
28
            || $colonyScan->getUser() !== $game->getUser()
29
        ) {
30
            return;
31
        }
32
33
        $this->colonyScanRepository->delete($colonyScan);
34
        $game->setView(Noop::VIEW_IDENTIFIER);
35
    }
36
37
    public function performSessionCheck(): bool
38
    {
39
        return true;
40
    }
41
}
42