PluginProbe
Disk Usage Insights / 1.5
Disk Usage Insights v1.5
trunk 1.0 1.10 1.11 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
disk-usage-insights / src / Frontend / Table.php

Table.php in Disk Usage Insights 1.5, at src/Frontend/Table.php

50 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Mgleis\DiskUsageInsights\Frontend;
3
4 class Table {
5
6 private /** @var string */ $headline;
7 private /** @var array */ $columnNames = [];
8 private /** @var array */ $columnCss = [];
9 private /** @var array */ $percentBar = null; // [$colDisplay, $colSource]
10 private /** @var array */ $data = [];
11
12 public function __construct(string $headline, array $columnNames = null, array $columnCss = null)
13 {
14 $this->headline = $headline;
15 if ($columnNames !== null) {
16 $this->columnNames = $columnNames;
17 }
18 if ($columnCss !== null) {
19 $this->columnCss = $columnCss;
20 }
21 }
22
23 public function withData(array $data): self {
24 $this->data = $data;
25
26 return $this;
27 }
28
29 public function output() {
30 $table = $this->data;
31 include __DIR__ . '/../../views/blocks/table.php';
32 }
33
34 public function withPercentBar(int $colDisplay, int $colSource): self {
35 $this->percentBar = [$colDisplay, $colSource];
36
37 return $this;
38 }
39
40 public function hasPercentBar($col): bool {
41 return $this->percentBar !== null
42 && $this->percentBar[0] === $col;
43 }
44
45 public function getPercentBar(int $row): float {
46 return floatval($this->data[$row][$this->percentBar[1]]);
47 }
48
49 }
50