$samples */ public function __construct( public readonly string $key, public readonly Severity $severity, public readonly int $count = 0, public readonly ?string $url = null, public readonly array $samples = [], ) {} /** * @param array $samples */ public static function problem( string $key, int $count, Severity $severity = Severity::Warning, ?string $url = null, array $samples = [], ): self { // A check that found nothing is a pass, whatever severity it would // have reported — so no caller has to remember to say so. if ($count < 1) { return self::ok($key, $url); } return new self($key, $severity, $count, $url, array_slice($samples, 0, 3)); } public static function ok(string $key, ?string $url = null): self { return new self($key, Severity::Ok, 0, $url); } public function title(): string { return __("health.checks.{$this->key}.title"); } /** * What it means and what to do about it — or, when there is nothing to do, * a plain statement that this one is fine. */ public function description(): string { return $this->severity->isProblem() ? trans_choice("health.checks.{$this->key}.problem", $this->count, ['count' => $this->count]) : __("health.checks.{$this->key}.ok"); } }