value = $value; $this->json = json_encode( $value, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_LINE_TERMINATORS ); $this->sha256 = hash('sha256', $this->json); } public static function fromSpec(array $spec): self { $fix = $spec['debian_12_network_fix'] ?? null; if (!is_bool($fix)) { throw new CloudError('备份缺少可信的 Debian 网络修正快照', 409); } $policy = CloudPlatformTestNetworkPolicy::assertSnapshot( $spec['platform_network_policy_snapshot'] ?? null ); return new self([ 'contract' => 1, 'debian_12_network_fix' => $fix, 'platform_network_policy_snapshot' => $policy, ]); } public function toArray(): array { return $this->value; } public function json(): string { return $this->json; } public function sha256(): string { return $this->sha256; } }