@@ -174,7 +174,22 @@ $map->mergeAssociative(...$others): static;
174
174
$map->mergePairs(...$others): static;
175
175
```
176
176
177
- Conversely, changes can be applied to ` OuterList ` and ` InnerList ` with adapted methods around list handling:
177
+ To Create ` OuterList ` and ` InnerList ` instances you can use the ` fromMembers ` name constructor:
178
+
179
+ ``` php
180
+ use Bakame\Http\StructuredFields\InnerList;
181
+ use Bakame\Http\StructuredFields\Item;
182
+
183
+ $list = InnerList::fromMembers(
184
+ Item::fromDecodedByteSequence('Hello World'),
185
+ 42.0,
186
+ 42
187
+ );
188
+
189
+ echo $list->toHttpValue(); //'(:SGVsbG8gV29ybGQ=: 42.0 42)'
190
+ echo $list; //'(:SGVsbG8gV29ybGQ=: 42.0 42)'
191
+ ```
192
+ Once again, builder methods exist on both classes to ease container construction.
178
193
179
194
``` php
180
195
use Bakame\Http\StructuredFields\InnerList;
@@ -199,8 +214,8 @@ $list->insert($key, ...$members): static;
199
214
$list->replace($key, $member): static;
200
215
```
201
216
202
- Last but not least you can attach, read and update a ` Parameters ` instance using the
203
- following methods on ` Item ` and ` InnerList ` instances :
217
+ On ` InnerList ` instances it is possible to attach, read and update a ` Parameters ` instance using the
218
+ following methods:
204
219
205
220
``` php
206
221
$field->parameter($key): mixed|null;
@@ -212,6 +227,18 @@ $field->withoutAnyParameter(): static;
212
227
$field->withParameters(Parameters $parameters): static;
213
228
```
214
229
230
+ It is possible to instantiate an ` InnerList ` instance with included parameters using one of those two additional named constructors:
231
+
232
+ ``` php
233
+ use Bakame\Http\StructuredFields\InnerList;
234
+ use Bakame\Http\StructuredFields\Value;
235
+
236
+ //@type DataType Value|ByteSequence|Token|DateTimeInterface|Stringable|string|int|float|bool
237
+
238
+ InnerList::fromAssociativeParameters(iterable<string , Value > $parameters, DataType ...$members): self;
239
+ InnerList::fromPairParameters(iterable<array {0:string, 1:DataType} >} $parameters, DataType ...$members): self;
240
+ ```
241
+
215
242
### Item and RFC Data Types
216
243
217
244
To handle an item, the package provide a specific ` Item ` value object with additional named constructors.
0 commit comments