ResponseEnvelope
Corex\Http\ResponseEnvelope · class · Core layer
The one canonical shape of every Corex response (spec 043). A pure, immutable value object built only via the named factories — never holds a secret, so it is safe to serialise straight to the wire (Principle VII). success → { ok:true, message, data } validation → { ok:false, code:‘validation_failed’, message, errors{}, details{} } error → { ok:false, code, message, details{} } EnvelopeResponder maps it to a WP_REST_Response; this object knows nothing about WordPress so it stays headlessly testable.
Public API
Section titled “Public API”success(array $data, string $message): self
Section titled “success(array $data, string $message): self”error(string $code, string $message, array $details): self
Section titled “error(string $code, string $message, array $details): self”validation(array $errors, string $message): self
Section titled “validation(array $errors, string $message): self”toArray(): array
Section titled “toArray(): array”The wire body — only the documented contract keys, in a stable order.