@@ -422,7 +422,7 @@ echo $value->toHttpValue(); //b=?0, a=(bar "42" 42 42.0), c=@1671800423
422
422
echo $value; //b=?0, a=(bar "42" 42 42.0), c=@1671800423
423
423
```
424
424
425
- ** ⚠️WARNING: on duplication parameters with the same ` keys ` are merged as per RFC logic.**
425
+ ** ⚠️WARNING: on duplicate ` keys ` pair values are merged as per RFC logic.**
426
426
427
427
#### Automatic conversion
428
428
@@ -437,21 +437,33 @@ If the submitted type is:
437
437
438
438
If no conversion is possible an ` InvalidArgument ` exception will be thrown.
439
439
440
- This means that the previous example can be rewritten like this:
440
+ This means that both constructs below built equal objects
441
441
442
442
``` php
443
443
use Bakame\Http\StructuredFields\Dictionary;
444
444
use Bakame\Http\StructuredFields\Item;
445
445
use Bakame\Http\StructuredFields\Token;
446
446
447
- $value = Dictionary::new()
447
+ echo Dictionary::new()
448
+ ->add('a', InnerList::new(
449
+ Item::fromToken('bar'),
450
+ Item::fromString('42'),
451
+ Item::fromInteger(42),
452
+ Item::fromDecimal(42)
453
+ ))
454
+ ->prepend('b', Item::false())
455
+ ->append('c', Item::fromDateString('2022-12-23 13:00:23'))
456
+ ->toHttpValue()
457
+ ;
458
+
459
+ echo Dictionary::new()
448
460
->add('a', [Token::fromString('bar'), '42', 42, 42.0])
449
461
->prepend('b', false)
450
462
->append('c', new DateTimeImmutable('2022-12-23 13:00:23'))
463
+ ->toHttpValue()
451
464
;
452
465
453
- echo $value->toHttpValue(); //b=?0, a=(bar "42" 42 42.0), c=@1671800423
454
- echo $value; //b=?0, a=(bar "42" 42 42.0), c=@1671800423
466
+ // both will return 'b=?0, a=(bar "42" 42 42.0), c=@1671800423
455
467
```
456
468
457
469
Of course, it is possible to mix both notation as shown in the example.
0 commit comments