# disk-usage-insights/1.5/src/Frontend/Table.php

Disk Usage Insights, version 1.5. 50 lines.

- Page: https://pluginprobe.com/plugins/disk-usage-insights/1.5/code/src/Frontend/Table.php
- Raw: https://pluginprobe.com/plugins/disk-usage-insights/1.5/raw/src/Frontend/Table.php
- Modified: 2025-03-16T17:27:12+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/disk-usage-insights/1.5/code/src/Frontend/Table.php#L10-L20`.

```php
<?php
namespace Mgleis\DiskUsageInsights\Frontend;

class Table {

    private /** @var string */ $headline;
    private /** @var array */ $columnNames = [];
    private /** @var array */ $columnCss = [];
    private /** @var array */ $percentBar = null; // [$colDisplay, $colSource]
    private /** @var array */ $data = [];

    public function __construct(string $headline, array $columnNames = null, array $columnCss = null)
    {
        $this->headline = $headline;
        if ($columnNames !== null) {
            $this->columnNames = $columnNames;
        }
        if ($columnCss !== null) {
            $this->columnCss = $columnCss;
        }
    }

    public function withData(array $data): self {
        $this->data = $data;

        return $this;
    }

    public function output() {
        $table = $this->data;
        include __DIR__ . '/../../views/blocks/table.php';
    }

    public function withPercentBar(int $colDisplay, int $colSource): self {
        $this->percentBar = [$colDisplay, $colSource];

        return $this;
    }

    public function hasPercentBar($col): bool {
        return $this->percentBar !== null
            && $this->percentBar[0] === $col;
    }

    public function getPercentBar(int $row): float {
        return floatval($this->data[$row][$this->percentBar[1]]);
    }

}

```
