1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Lib\Map\VisualPanel; |
6
|
|
|
|
7
|
|
|
use Stu\Lib\Map\VisualPanel\VisualPanelRow; |
8
|
|
|
use Stu\Module\Logging\LoggerUtilInterface; |
9
|
|
|
|
10
|
|
|
abstract class AbstractVisualPanel |
11
|
|
|
{ |
12
|
|
|
protected LoggerUtilInterface $loggerUtil; |
13
|
|
|
|
14
|
|
|
/** @var null|array<int, VisualPanelRow> */ |
15
|
|
|
private ?array $rows = null; |
16
|
|
|
|
17
|
|
|
/** @var null|array<array{value: int}> */ |
18
|
|
|
protected ?array $headRow = null; |
19
|
|
|
|
20
|
|
|
private ?float $viewport = null; |
21
|
|
|
|
22
|
|
|
private ?string $viewportPerColumn = null; |
23
|
|
|
|
24
|
|
|
private ?string $viewportForFont = null; |
25
|
|
|
|
26
|
1 |
|
public function __construct( |
27
|
|
|
LoggerUtilInterface $loggerUtil |
28
|
|
|
) { |
29
|
1 |
|
$this->loggerUtil = $loggerUtil; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @return array<array{value: int}> |
34
|
|
|
*/ |
35
|
|
|
public abstract function getHeadRow(): array; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @return array<int, VisualPanelRow> |
39
|
|
|
*/ |
40
|
|
|
public function getRows(): array |
41
|
|
|
{ |
42
|
|
|
if ($this->rows === null) { |
43
|
|
|
$this->rows = $this->loadLSS(); |
44
|
|
|
} |
45
|
|
|
return $this->rows; |
|
|
|
|
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return array<VisualPanelRow> |
50
|
|
|
*/ |
51
|
|
|
protected abstract function loadLSS(): array; |
52
|
|
|
|
53
|
|
|
protected abstract function getPanelViewportPercentage(): int; |
54
|
|
|
|
55
|
|
|
private function getViewport(): float |
56
|
|
|
{ |
57
|
|
|
if ($this->viewport === null) { |
58
|
|
|
$navPercentage = 100; |
59
|
|
|
$perColumn = $navPercentage / count($this->getHeadRow()); |
60
|
|
|
$this->viewport = min($perColumn, 1.7); |
61
|
|
|
} |
62
|
|
|
return $this->viewport; |
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getViewportPerColumn(): string |
66
|
|
|
{ |
67
|
|
|
if ($this->viewportPerColumn === null) { |
68
|
|
|
$this->viewportPerColumn = number_format($this->getViewport(), 1); |
69
|
|
|
} |
70
|
|
|
return $this->viewportPerColumn; |
|
|
|
|
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function getViewportForFont(): string |
74
|
|
|
{ |
75
|
|
|
if ($this->viewportForFont === null) { |
76
|
|
|
$this->viewportForFont = number_format($this->getViewport() / 2, 1); |
77
|
|
|
} |
78
|
|
|
return $this->viewportForFont; |
|
|
|
|
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|