@@ -69,11 +69,11 @@ header. Content validation is out of scope for this library.
69
69
> [ !NOTE]
70
70
> New in version 1.2.0
71
71
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.
77
77
78
78
``` php
79
79
$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
82
82
$field->parameter('baz'); // returns 42; the value of the parameter or null if the parameter is not defined.
83
83
```
84
84
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.
88
87
89
88
``` php
90
89
use Bakame\Http\StructuredFields\Item;
@@ -106,9 +105,9 @@ echo DataType::List->build([
106
105
#### Using specific named constructor
107
106
108
107
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:
112
111
113
112
``` php
114
113
declare(strict_types=1);
@@ -154,7 +153,7 @@ All five (5) structured data type as defined in the RFC are provided inside the
154
153
- ` OuterList ` (named ` List ` in the RFC but renamed in the package because ` list ` is a reserved word in PHP.)
155
154
- ` InnerList `
156
155
157
- #### Advance usage
156
+ #### Advance parsing usage
158
157
159
158
Starting with version ` 1.1 ` the internal parser has been made public in order to allow:
160
159
@@ -217,16 +216,24 @@ Per the RFC, items can have different types that are translated to PHP using:
217
216
218
217
The table below summarizes the item value type.
219
218
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,
230
237
231
238
The Enum ` Type ` which list all available types can be used to determine the RFC type
232
239
corresponding to a PHP structure using the ` Type::fromVariable ` static method.
0 commit comments