PluginProbe
Disk Usage Insights / 1.6
Disk Usage Insights v1.6
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.6, at src/Frontend/Table.php

58 lines 1.5 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 private ?Pagination $pagination = null;
12
13 public function __construct(string $headline, array $columnNames = [], array $columnCss = [])
14 {
15 $this->headline = $headline;
16 if ($columnNames !== null) {
17 $this->columnNames = $columnNames;
18 }
19 if ($columnCss !== null) {
20 $this->columnCss = $columnCss;
21 }
22 }
23
24 public function withData(array $data): self {
25 $this->data = $data;
26
27 return $this;
28 }
29
30 public function output() {
31 $table = $this->data;
32 $pagination = $this->pagination;
33 include __DIR__ . '/../../views/blocks/table.php';
34 }
35
36 public function withPercentBar(int $colDisplay, int $colSource): self {
37 $this->percentBar = [$colDisplay, $colSource];
38
39 return $this;
40 }
41
42 public function withPagination(Pagination $pagination): self {
43 $this->pagination = $pagination;
44
45 return $this;
46 }
47
48 public function hasPercentBar($col): bool {
49 return $this->percentBar !== null
50 && $this->percentBar[0] === $col;
51 }
52
53 public function getPercentBar(int $row): float {
54 return floatval($this->data[$row][$this->percentBar[1]]);
55 }
56
57 }
58