Conditions | 7 |
Paths | 12 |
Total Lines | 44 |
Code Lines | 31 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 56 |
Changes | 0 |
1 | <?php |
||
26 | public function setTemplateVariables(GameControllerInterface $game): void |
||
27 | { |
||
28 | $type = HistoryTypeEnum::tryFrom(request::indInt('htype')) ?? HistoryTypeEnum::SHIP; |
||
29 | $count = request::indInt('hcount'); |
||
30 | if (!$count) { |
||
31 | $count = self::LIMIT; |
||
32 | } |
||
33 | $search = request::indString('hsearch'); |
||
34 | |||
35 | if ($count < 1 || $count > self::MAX_LIMIT) { |
||
36 | $count = self::MAX_LIMIT; |
||
37 | } |
||
38 | |||
39 | $history_types = []; |
||
40 | foreach (HistoryTypeEnum::cases() as $enum) { |
||
41 | $key = $enum->value; |
||
42 | $history_types[$key]['type'] = $enum; |
||
43 | $history_types[$key]['class'] = $enum == $type ? 'selected' : ''; |
||
44 | $history_types[$key]['count'] = $this->historyRepository->getAmountByType($key); |
||
45 | } |
||
46 | |||
47 | $game->setTemplateVar( |
||
48 | 'HISTORY_TYPE', |
||
49 | $type |
||
50 | ); |
||
51 | $game->setTemplateVar( |
||
52 | 'HISTORY_TYPE_COUNT', |
||
53 | count($history_types) |
||
54 | ); |
||
55 | $game->setTemplateVar( |
||
56 | 'HISTORY_TYPES', |
||
57 | $history_types |
||
58 | ); |
||
59 | $game->setTemplateVar( |
||
60 | 'HISTORY_COUNT', |
||
61 | $count |
||
62 | ); |
||
63 | $game->setTemplateVar( |
||
64 | 'HISTORY_SEARCH', |
||
65 | $search ?: '' |
||
|
|||
66 | ); |
||
67 | $game->setTemplateVar( |
||
68 | 'HISTORY', |
||
69 | $this->historyRepository->getByTypeAndSearch($type, $count, $search) |
||
70 | ); |
||
73 |