fedi-feed-router/app/Dashboard/Stats/Series.php

31 lines
704 B
PHP

<?php
namespace App\Dashboard\Stats;
class Series
{
/**
* @param array<int, int|float|null> $values
* @param bool $zeroIsMeaningful A rate of 0 is a real measurement; a count of 0 is an absence.
*/
public function __construct(
public readonly string $name,
public readonly array $values,
public readonly bool $zeroIsMeaningful = false,
) {}
public function hasData(): bool
{
foreach ($this->values as $value) {
if ($value === null) {
continue;
}
if ($this->zeroIsMeaningful || $value != 0) {
return true;
}
}
return false;
}
}