Initial commit: Pireon Admin — headless admin panel and public API
Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer collective, backed by the Pireon OAuth identity server. The public site is a separate, server-rendered application consuming /api/public/v1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
66
app/Support/Health/Finding.php
Normal file
66
app/Support/Health/Finding.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Support\Health;
|
||||
|
||||
/**
|
||||
* The outcome of one check.
|
||||
*
|
||||
* Carries a few example records on purpose. "12 pages have no description" is
|
||||
* a statistic; "12, starting with *Quiénes somos*" is something somebody can
|
||||
* act on without hunting for the first one.
|
||||
*/
|
||||
final class Finding
|
||||
{
|
||||
/**
|
||||
* @param array<int, string> $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<int, string> $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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user