30 lines
522 B
PHP
30 lines
522 B
PHP
<?php
|
|
|
|
namespace App\Reports;
|
|
|
|
use App\Reports\Contracts\Report;
|
|
|
|
class ReportRegistry
|
|
{
|
|
/** @var array<string, Report> */
|
|
protected array $reports = [];
|
|
|
|
public function register(Report $report): void
|
|
{
|
|
$this->reports[$report->slug()] = $report;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, Report>
|
|
*/
|
|
public function all(): array
|
|
{
|
|
return $this->reports;
|
|
}
|
|
|
|
public function findBySlug(string $slug): ?Report
|
|
{
|
|
return $this->reports[$slug] ?? null;
|
|
}
|
|
}
|