Skip to content

Commit dd745af

Browse files
committed
Update documentation
1 parent 8f13d4f commit dd745af

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed

README.md

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ header. Content validation is out of scope for this library.
6969
> [!NOTE]
7070
> New in version 1.2.0
7171
72-
The `DataType` enum list all available data type according to the RFC. It is also a
73-
Factory to enable parsing and building such data types. To parse a header you need
74-
to give the `parse` method a string or a stringable object. On success, it will
75-
return a `Bakame\Http\StruncturedFields\StruncturedField` implementing object
76-
otherwise an exception will be thrown.
72+
The `DataType` enum list all five (5) available data type according to the RFC. It is also a
73+
Factory to enable parsing and building such data types. To parse a field you need to give
74+
the `parse` method a string or a stringable object representing the field text
75+
representation. On success, it will return a `StruncturedField` implementing
76+
object otherwise an exception will be thrown.
7777

7878
```php
7979
$headerLine = 'bar;baz=42'; //the raw header line is a structured field item
@@ -82,9 +82,8 @@ $field->value(); // returns Token::fromString('bar); the found token va
8282
$field->parameter('baz'); // returns 42; the value of the parameter or null if the parameter is not defined.
8383
```
8484

85-
On the other hand, `build` method expects an iterable structure composed
86-
of pair values that matches each data type and returns the structured field text representation
87-
of the header.
85+
On the other hand, `build` method expects an iterable structure composed of pair values
86+
that matches any structured field data type and returns its text representation.
8887

8988
```php
9089
use Bakame\Http\StructuredFields\Item;
@@ -106,9 +105,9 @@ echo DataType::List->build([
106105
#### Using specific named constructor
107106

108107
To complement the factory and to allow for more fine-grained manipulations, the package
109-
provides specific classes for each data type. if you do not wish to use the `DataType`
110-
factoring, parsing the header value is done via the `fromHttpValue` named constructor.
111-
The method is attached to each library's structured fields representation as shown below:
108+
also provides specific classes for each data type. Parsing the header value is done
109+
via the `fromHttpValue` named constructor. The method is attached to each
110+
library's structured fields representation as shown below:
112111

113112
```php
114113
declare(strict_types=1);
@@ -154,7 +153,7 @@ All five (5) structured data type as defined in the RFC are provided inside the
154153
- `OuterList` (named `List` in the RFC but renamed in the package because `list` is a reserved word in PHP.)
155154
- `InnerList`
156155

157-
#### Advance usage
156+
#### Advance parsing usage
158157

159158
Starting with version `1.1` the internal parser has been made public in order to allow:
160159

@@ -217,16 +216,24 @@ Per the RFC, items can have different types that are translated to PHP using:
217216

218217
The table below summarizes the item value type.
219218

220-
| RFC Type | PHP Type | Package Enum Type |
221-
|---------------|---------------------------|-----------------------|
222-
| Integer | `int` | `Type::Integer` |
223-
| Decimal | `float` | `Type::Decimal` |
224-
| String | `string` | `Type::String` |
225-
| Boolean | `bool` | `Type::Boolean` |
226-
| Token | class `Token` | `Type::Token` |
227-
| Byte Sequence | class `ByteSequence` | `Type::ByteSequence` |
228-
| Date | class `DateTimeImmutable` | `Type::Date` |
229-
| DisplayString | class `DisplayString` | `Type::DisplayString` |
219+
| RFC Type | PHP Type | Package Enum Type |
220+
|-------------------|---------------------------|-----------------------|
221+
| Integer | `int` | `Type::Integer` |
222+
| Decimal | `float` | `Type::Decimal` |
223+
| String | `string` | `Type::String` |
224+
| Boolean | `bool` | `Type::Boolean` |
225+
| Token | class `Token` | `Type::Token` |
226+
| Byte Sequence | class `ByteSequence` | `Type::ByteSequence` |
227+
| Date (*) | class `DateTimeImmutable` | `Type::Date` |
228+
| DisplayString (*) | class `DisplayString` | `Type::DisplayString` |
229+
230+
> [!NOTE]
231+
> The `Date` and `DisplayString` type are not yet part of any accepted
232+
> RFC. But they are already added as new types in the superseeding
233+
> RFC proposal.
234+
>
235+
> See https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-sfbis
236+
> for more information,
230237
231238
The Enum `Type` which list all available types can be used to determine the RFC type
232239
corresponding to a PHP structure using the `Type::fromVariable` static method.

0 commit comments

Comments
 (0)