Skip to content

Commit f657448

Browse files
committed
Update class attribution and documentation
1 parent c9be980 commit f657448

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

README.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Structured Field Values for PHP
66
[![Build](https://github.com/bakame-php/http-structured-fields/workflows/build/badge.svg)](https://github.com/bakame-php/http-structured-fields/actions?query=workflow%3A%22build%22)
77

88
The package uses pragmatic value objects to parse and serialize [HTTP Structured Fields][1] in PHP.
9+
910
HTTP Structured fields are intended for use by specifications of new HTTP fields that wish to
1011
use a common syntax that is more restrictive than traditional HTTP field values or could be
1112
used to [retrofit current headers](https://www.ietf.org/id/draft-ietf-httpbis-retrofit-00.html) to have them compliant with the new syntax.
@@ -44,12 +45,12 @@ Documentation
4445

4546
There are three top-level types that an HTTP field can be defined as:
4647

48+
- Dictionaries,
4749
- Lists,
48-
- Dictionaries,
4950
- and Items.
5051

51-
For each of those top-level types, the package provide a dedicated value object to parse the textual representation of the field
52-
and to serialize the value object back to the textual representation.
52+
For each of those top-level types, the package provide a dedicated value object to parse the textual
53+
representation of the field and to serialize the value object back to the textual representation.
5354

5455
- Parsing is done via a common named constructor `fromHttpValue` which expects the Header or Trailer string value.
5556
- Serializing is done via a common `toHttpValue` public method. The method returns the normalized string representation suited for HTTP textual representation.
@@ -69,14 +70,19 @@ $item = Item::fromHttpValue('"foo";a=1;b=2"');
6970
echo $item->toHttpValue(); // "foo";a=1;b=2
7071
```
7172

72-
## Manipulating Structured Fields Value Objects
73+
## Manipulating Structured Fields Data Types
74+
75+
The RFC defines different data types to handle structured fields values.
7376

7477
### Items
7578

79+
The Item may be considered the minimal building block for structired fields the following explains how to build
80+
and interact with them.
81+
7682
#### Types
7783

78-
Item types [defined in the RFC](https://www.rfc-editor.org/rfc/rfc8941.html#section-3.3) are translated to PHP native type when possible.
79-
Two additional classes
84+
Item have different types [defined in the RFC](https://www.rfc-editor.org/rfc/rfc8941.html#section-3.3). They are
85+
translated to PHP native type when possible. Two additional classes
8086

8187
- `Bakame\Http\StructuredFields\Token` and
8288
- `Bakame\Http\StructuredFields\ByteSequence`
@@ -137,16 +143,16 @@ $item->isInteger(); //return true
137143
Apart from the `Item`, the RFC defines different containers with different requirements. The
138144
package exposes those containers via the following value objects:
139145

140-
- `Parameters`,
141146
- `Dictionary`,
142-
- `InnerList`,
143-
- and `OrderedList` to represent a generic list,
144-
147+
- `Parameters`,
148+
- `OrderedList`,
149+
- and `InnerList`
150+
145151
At any given time it is possible with each of these objects to:
146152

147-
- iterate over each contained element and its optional associated key via the `IteratorAggregate` interface;
153+
- iterate over each contained member and its optional associated key via the `IteratorAggregate` interface;
148154
- tell whether the container is empty via an `isEmpty` method;
149-
- know the number of elements contained in the container via the `Countable` interface;
155+
- know the number of members contained in the container via the `Countable` interface;
150156
- merge multiple instance of **the same type** using the `merge` method;
151157
- clear the container using the `clear` method;
152158

@@ -250,7 +256,7 @@ Contributions are welcome and will be fully credited. Please see [CONTRIBUTING](
250256
Testing
251257
-------
252258

253-
The library :
259+
The library:
254260

255261
- has a [PHPUnit](https://phpunit.de) test suite
256262
- has a coding style compliance test suite using [PHP CS Fixer](https://cs.sensiolabs.org/).

src/Parser.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
/**
88
* A parser to create HTTP Structured Fields value objects from HTTP textual representation.
99
*
10+
* Based on gapple\StructuredFields\Parser class in Structured Field Values for PHP v1.0.0.
11+
* @link https://github.com/gapple/structured-fields/blob/v1.0.0/src/Parser.php
12+
*
1013
* @see https://www.rfc-editor.org/rfc/rfc8941.html#section-4.2
1114
*
1215
* @internal Use OrderedList::fromHttpValue() or Dictionary::fromHttpValue() instead

0 commit comments

Comments
 (0)