*/ class Implementation implements \JsonSerializable { public function __construct( public readonly string $name = 'app', public readonly string $version = 'dev', public readonly ?string $description = null, ) { } /** * @param array{ * name: string, * version: string, * } $data */ public static function fromArray(array $data): self { if (empty($data['name']) || !\is_string($data['name'])) { throw new InvalidArgumentException('Invalid or missing "name" in Implementation data.'); } if (empty($data['version']) || !\is_string($data['version'])) { throw new InvalidArgumentException('Invalid or missing "version" in Implementation data.'); } return new self($data['name'], $data['version'], $data['description'] ?? null); } /** * @return array{ * name: string, * version: string, * } */ public function jsonSerialize(): array { $data = [ 'name' => $this->name, 'version' => $this->version, ]; if (null !== $this->description) { $data['description'] = $this->description; } return $data; } }