Shorthand for structured body values #12

Closed
opened 2026-04-28 20:32:15 +02:00 by c.fahner · 2 comments
Owner

Currently the expected method of obtaining keys from a structured request body (JSON, form data, etc.) looks like this:

if ($request->body instanceof Structured) {
  $data = $request->body->root;
  if (isset($data['myKey'])) {
    // do something with the value
  }
}

A Message\Body utility class should be created for the same reasons mentioned in #6. The utility methods should directly accept any Message instance. The utility class should also provide a toString() method, which concatenates each part of the body iterator into a single string.

Currently the expected method of obtaining keys from a structured request body (JSON, form data, etc.) looks like this: ```php if ($request->body instanceof Structured) { $data = $request->body->root; if (isset($data['myKey'])) { // do something with the value } } ``` A `Message\Body` utility class should be created for the same reasons mentioned in #6. The utility methods should directly accept any `Message` instance. The utility class should also provide a `toString()` method, which concatenates each part of the body iterator into a single string.
c.fahner added this to the v0.2 milestone 2026-04-28 20:32:15 +02:00
Author
Owner

Decided to name it BodyArgs instead.

Decided to name it `BodyArgs` instead.
c.fahner referenced this issue from a commit 2026-04-30 20:28:52 +02:00
c.fahner stopped working 2026-04-30 20:29:15 +02:00
39 minutes 34 seconds
Author
Owner

Closed by !20

Closed by !20
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Total time spent: 39 minutes 34 seconds
c.fahner
39 minutes 34 seconds
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
slendium/http#12
No description provided.