Skip to content

Commit f9722c6

Browse files
committed
Update documentation
1 parent d436163 commit f9722c6

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

README.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,22 @@ $map->mergeAssociative(...$others): static;
174174
$map->mergePairs(...$others): static;
175175
```
176176

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.
178193

179194
```php
180195
use Bakame\Http\StructuredFields\InnerList;
@@ -199,8 +214,8 @@ $list->insert($key, ...$members): static;
199214
$list->replace($key, $member): static;
200215
```
201216

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:
204219

205220
```php
206221
$field->parameter($key): mixed|null;
@@ -212,6 +227,18 @@ $field->withoutAnyParameter(): static;
212227
$field->withParameters(Parameters $parameters): static;
213228
```
214229

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+
215242
### Item and RFC Data Types
216243

217244
To handle an item, the package provide a specific `Item` value object with additional named constructors.

0 commit comments

Comments
 (0)