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