TenantAtlas/app/Support/Ui/EnterpriseDetail/EnterpriseDetailPageData.php
2026-03-11 00:05:33 +01:00

65 lines
2.6 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Support\Ui\EnterpriseDetail;
final readonly class EnterpriseDetailPageData
{
/**
* @param list<DetailSectionData> $mainSections
* @param list<SupportingCardData> $supportingCards
* @param list<TechnicalDetailData> $technicalSections
* @param list<array{title: string, description?: ?string, icon?: ?string}> $emptyStateNotes
*/
public function __construct(
public string $resourceType,
public string $scope,
public SummaryHeaderData $header,
public array $mainSections = [],
public array $supportingCards = [],
public array $technicalSections = [],
public array $emptyStateNotes = [],
) {}
/**
* @return array{
* resourceType: string,
* scope: string,
* header: array{
* title: string,
* subtitle: ?string,
* statusBadges: list<array{label: string, color?: string, icon?: ?string, iconColor?: ?string}>,
* keyFacts: list<array{label: string, value: string, hint?: ?string, badge?: ?array{label: string, color?: string, icon?: ?string, iconColor?: ?string}}>,
* primaryActions: list<array{label: string, placement: string, url: ?string, actionName: ?string, destructive: bool, requiresConfirmation: bool, visible: bool, icon: ?string, openInNewTab: bool}>,
* descriptionHint: ?string
* },
* mainSections: list<array<string, mixed>>,
* supportingCards: list<array<string, mixed>>,
* technicalSections: list<array<string, mixed>>,
* emptyStateNotes: list<array{title: string, description?: ?string, icon?: ?string}>
* }
*/
public function toArray(): array
{
return [
'resourceType' => $this->resourceType,
'scope' => $this->scope,
'header' => $this->header->toArray(),
'mainSections' => array_values(array_map(
static fn (DetailSectionData $section): array => $section->toArray(),
$this->mainSections,
)),
'supportingCards' => array_values(array_map(
static fn (SupportingCardData $card): array => $card->toArray(),
$this->supportingCards,
)),
'technicalSections' => array_values(array_map(
static fn (TechnicalDetailData $section): array => $section->toArray(),
$this->technicalSections,
)),
'emptyStateNotes' => array_values($this->emptyStateNotes),
];
}
}