Files
WP-LIT-MCP/src/Integrations/Divi/Release/FeatureStatus.php
T

50 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace LIT\MCP\Integrations\Divi\Release;
defined('ABSPATH') || exit;
/** The release state of one Divi feature (E1): released (with its source), untested or incompatible. */
final class FeatureStatus
{
/**
* @param list<string> $problems Labels of the problems behind the state (Problem::$label).
* @param string|null $source For a released feature: ReleaseStatus::SOURCE_CODE, SOURCE_DATABASE or
* SOURCE_AUTO; null otherwise.
*/
public function __construct(
public readonly DiviFeature $feature,
public readonly ReleaseState $state,
public readonly array $problems = [],
public readonly ?string $source = null
) {
}
public function usable(): bool
{
return $this->state === ReleaseState::Released;
}
/** @return array{id: string, label: string, state: string, problems: list<string>} For refusals (D6). */
public function summary(): array
{
return [
'id' => $this->feature->value,
'label' => $this->feature->label(),
'state' => $this->state->value,
'problems' => $this->problems,
];
}
/**
* @return array{id: string, label: string, state: string, problems: list<string>, source: ?string}
* For lit-site-status and the admin tab.
*/
public function toArray(): array
{
return $this->summary() + ['source' => $this->source];
}
}