Files
onboard/app/Services/Analytics/AnalyticsResult.php

31 lines
762 B
PHP

<?php
namespace App\Services\Analytics;
/**
* Результат построения отчёта: описания колонок, строки и итоги.
*/
readonly class AnalyticsResult
{
/**
* @param Column[] $columns
* @param array<int,array<string,mixed>> $rows
* @param array<string,mixed> $totals
*/
public function __construct(
public array $columns,
public array $rows,
public array $totals = [],
) {}
/** @return array<string,mixed> */
public function toArray(): array
{
return [
'columns' => array_map(fn (Column $c) => $c->toArray(), $this->columns),
'rows' => $this->rows,
'totals' => $this->totals,
];
}
}