$id, 'action' => 'stage', 'target' => $target, 'at' => time()]; @mkdir($this->dir(), 0775, true); $ok = @file_put_contents($this->dir().'/release-request.json', json_encode($payload, JSON_UNESCAPED_SLASHES)); return $ok === false ? null : $id; } /** * Read the host result for an id THIS app issued. Null until the result exists. Never throws. * * @return array{ok:bool, tag:?string, message:string}|null */ public function result(string $id): ?array { if (preg_match('/^[A-Za-z0-9]{16,64}$/', $id) !== 1) { return null; } $file = $this->dir()."/release-result-{$id}.json"; if (! is_file($file)) { return null; } $data = json_decode((string) @file_get_contents($file), true); if (! is_array($data) || ($data['id'] ?? null) !== $id) { return null; } return [ 'ok' => (bool) ($data['ok'] ?? false), 'tag' => isset($data['tag']) && is_string($data['tag']) ? $data['tag'] : null, 'message' => (string) ($data['message'] ?? ''), ]; } }