Skip to content

Commit fd5e26f

Browse files
committed
Improve documentation examples
1 parent c3951c4 commit fd5e26f

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ echo $value->toHttpValue(); //b=?0, a=(bar "42" 42 42.0), c=@1671800423
422422
echo $value; //b=?0, a=(bar "42" 42 42.0), c=@1671800423
423423
```
424424

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.**
426426

427427
#### Automatic conversion
428428

@@ -437,21 +437,33 @@ If the submitted type is:
437437

438438
If no conversion is possible an `InvalidArgument` exception will be thrown.
439439

440-
This means that the previous example can be rewritten like this:
440+
This means that both constructs below built equal objects
441441

442442
```php
443443
use Bakame\Http\StructuredFields\Dictionary;
444444
use Bakame\Http\StructuredFields\Item;
445445
use Bakame\Http\StructuredFields\Token;
446446

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()
448460
->add('a', [Token::fromString('bar'), '42', 42, 42.0])
449461
->prepend('b', false)
450462
->append('c', new DateTimeImmutable('2022-12-23 13:00:23'))
463+
->toHttpValue()
451464
;
452465

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
455467
```
456468

457469
Of course, it is possible to mix both notation as shown in the example.

0 commit comments

Comments
 (0)