Test Failed
Push — dev ( 985fdf...79dec8 )
by Nico
14:06
created

ShowAnalyseBuoy::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 28
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 15
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 28
rs 9.7666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Ship\View\ShowAnalyseBuoy;
6
7
use request;
8
use Stu\Module\Control\GameControllerInterface;
9
use Stu\Module\Control\ViewControllerInterface;
10
use Stu\Orm\Repository\BuoyRepositoryInterface;
11
12
final class ShowAnalyseBuoy implements ViewControllerInterface
13
{
14
    public const VIEW_IDENTIFIER = 'SHOW_ANALYSE_BUOY';
15
16
    private BuoyRepositoryInterface $buoyRepository;
17
18
19
    public function __construct(
20
        BuoyRepositoryInterface $buoyRepository
21
    ) {
22
        $this->buoyRepository = $buoyRepository;
23
    }
24
25
    public function handle(GameControllerInterface $game): void
26
    {
27
        $user = $game->getUser();
28
29
        $buoy = $this->buoyRepository->find(
30
            request::indInt('id')
31
        );
32
33
34
        $game->setPageTitle("Boje analysieren");
35
        $game->setMacroInAjaxWindow('html/shipmacros.xhtml/analysebuoy');
36
37
        $game->setTemplateVar('ERROR', true);
38
39
        if ($buoy !== null) {
40
            $amplitude = $buoy->getId() * $buoy->getUserId();
41
        } else {
42
            $amplitude = 0;
43
        }
44
        $wavelength = ceil($amplitude / 2);
45
46
        $game->setTemplateVar('AMPLITUDE', $amplitude);
47
        $game->setTemplateVar('WAVELENGTH', $wavelength);
48
49
50
51
        $game->setTemplateVar('BUOY', $buoy);
52
        $game->setTemplateVar('USER', $user);
53
    }
54
}
55