@@ -63,6 +63,8 @@ header. Content validation is out of scope for this library.**
6363
6464### Parsing and Serializing Structured Fields
6565
66+ #### Basic usage
67+
6668Parsing the header value is done via the ` fromHttpValue ` named constructor.
6769The method is attached to each library's structured fields representation
6870as shown below:
@@ -115,14 +117,27 @@ All five (5) structured data type as defined in the RFC are provided inside the
115117
116118#### Advance usage
117119
118- In order to allow:
120+ Starting with version ` 1.1 ` the internal parser has been made public in order to allow:
119121
120122- clearer decoupling betwen parsing and objet building
121123- different parsers implementations
122124- improve the package usage in testing.
123125
124- Starting with version ` 1.1 ` the internal parser has been made public. The class exposes
125- the following method each belonging to a different contract or interface.
126+ Each ` fromHttpValue ` method signature has been updated to take a second optional argument
127+ that represents the parser interface to use in order to allow parsing of the HTTP string
128+ representation value.
129+
130+ By default, if no parser is provided, the package will default to use the package ` Parser ` class,
131+
132+ ``` php
133+ Item::fromHttpValue(Stringable|string $httpValue, ItemParser $parser = new Parser()): Item;
134+ InnerList::fromHttpValue(Stringable|string $httpValue, InnerListParser $parser = new Parser()): InnerList;
135+ Dictionary::fromHttpValue(Stringable|string $httpValue, DictionaryParser $parser = new Parser()): Dictionary;
136+ OuterList::fromHttpValue(Stringable|string $httpValue, ListParser $parser = new Parser()): OuterList;
137+ Parameters::fromHttpValue(Stringable|string $httpValue, ParametersParser $parser = new Parser()): Parameters;
138+ ```
139+
140+ The ` Parser ` class exposes the following method each belonging to a different contract or interface.
126141
127142``` php
128143Parser::parseValue(Stringable|string $httpValue): ByteSequence|Token|DateTimeImmutable|string|int|float|bool;
@@ -133,8 +148,7 @@ Parser::parseList(Stringable|string $httpValue): array;
133148Parser::parseDictionary(Stringable|string $httpValue): array;
134149```
135150
136- While the provided default ` Parser ` class implements all these methods
137- you are free to only implement the methods you need.
151+ Once instantiated, calling one of the above listed method is straightforward:
138152
139153``` php
140154use Bakame\Http\StructuredFields\Parser;
@@ -149,19 +163,8 @@ $parser->parseItem('@1234567890;file=24');
149163// ]
150164```
151165
152- Each ` fromHttpValue ` method signature has been updated to take a second optional argument
153- that represents the parser interface to use in order to allow parsing of the HTTP string
154- representation value.
155-
156- By default, if no parser is provided, the package will default to use the package ` Parser ` class,
157-
158- ``` php
159- Item::fromHttpValue(Stringable|string $httpValue, ItemParser $parser = new Parser()): Item;
160- InnerList::fromHttpValue(Stringable|string $httpValue, InnerListParser $parser = new Parser()): InnerList;
161- Dictionary::fromHttpValue(Stringable|string $httpValue, DictionaryParser $parser = new Parser()): Dictionary;
162- OuterList::fromHttpValue(Stringable|string $httpValue, ListParser $parser = new Parser()): OuterList;
163- Parameters::fromHttpValue(Stringable|string $httpValue, ParametersParser $parser = new Parser()): Parameters;
164- ```
166+ ** While the provided default ` Parser ` class implements all these methods you are free to only implement
167+ the methods you need.**
165168
166169### Accessing Structured Fields Values
167170
@@ -406,7 +409,7 @@ $map->append(string $key, $value): static;
406409$map->prepend(string $key, $value): static;
407410$map->mergeAssociative(...$others): static;
408411$map->mergePairs(...$others): static;
409- $map->remove(string ...$key): static;
412+ $map->remove(string|int ...$key): static;
410413```
411414
412415As shown below:
@@ -474,6 +477,19 @@ echo $value; //b=?0, a=(bar "42" 42 42.0), c=@1671800423
474477
475478** ⚠️WARNING: on duplicate ` keys ` pair values are merged as per RFC logic.**
476479
480+ The ` remove ` always accepted string or integer as input. Since version ` 1.1 ` it will also remove
481+ the corresponding pair if its index is given to the method.
482+
483+ ``` diff
484+ <?php
485+
486+ use Bakame\Http\StructuredFields\Dictionary;
487+
488+ $field = Dictionary::fromHttpValue('b=?0, a=(bar "42" 42 42.0), c=@1671800423');
489+ - echo $field->remove('b', 2)->toHttpValue(); // returns a=(bar "42" 42 42.0), c=@1671800423
490+ + echo $field->remove('b', 2)->toHttpValue(); // returns a=(bar "42" 42 42.0)
491+ ```
492+
477493#### Automatic conversion
478494
479495For all containers, to ease instantiation the following automatic conversion are applied on
0 commit comments