@@ -335,18 +335,23 @@ use Bakame\Http\StructuredFields\Item;
335335use Bakame\Http\StructuredFields\Token;
336336
337337$value = Dictionary::new()
338- ->add('a', Item::fromToken('bar'))
338+ ->add('a', InnerList::new( Item::fromToken('bar'), tem::fromString ('bar'))
339339 ->prepend('b', Item::false())
340340 ->append('c', Item::fromDateString('2022-12-23 13:00:23'))
341341;
342342
343- echo $value->toHttpValue(); //" b=?0, a=bar, c=@1671800423"
344- echo $value; //" b=?0, a=bar, c=@1671800423"
343+ echo $value->toHttpValue(); //b=?0, a=( bar "bar") , c=@1671800423
344+ echo $value; //b=?0, a=( bar "bar") , c=@1671800423
345345```
346346
347- ** Of note: For all containers, if the submitted type is not a ` StructuredField `
348- implementing object, it will be passed to ` Item::new ` to convert it into a
349- bare ` Item ` instances.**
347+ #### Automatic conversion.
348+
349+ For all containers to ease instantiaiton the following automatic conversion are applied on
350+ the member argument of each modifying methods, if the submitted type is:
351+
352+ - a ` StructuredField ` implementing object, it will be passed as is
353+ - an iterable structure it will be converted to an ` InnerList ` instance using ` InnerList::new `
354+ - otherwise the value will be converted to an ` Item ` using ` Item::new ` .
350355
351356This means that the previous example can be rewritten like this:
352357
@@ -356,7 +361,7 @@ use Bakame\Http\StructuredFields\Item;
356361use Bakame\Http\StructuredFields\Token;
357362
358363$value = Dictionary::new()
359- ->add('a', 'bar')
364+ ->add('a', [Token::fromString( 'bar'), 'bar'] )
360365 ->prepend('b', false)
361366 ->append('c', new DateTimeImmutable('2022-12-23 13:00:23'))
362367;
0 commit comments