Skip to content

Commit 7def8ce

Browse files
committed
Update package documentation
1 parent 41bed8d commit 7def8ce

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ There are three top-level types that an HTTP field can be defined as:
4848
For each of those top-level types, the package provide a dedicated value object to parse the textual representation of the field
4949
and to serialize the value object back to the textual representation.
5050

51-
- Parsing is done via a common named constructor `fromHttpValue`.
52-
- Serializing is done via a common `toField` public method.
51+
- Parsing is done via a common named constructor `fromHttpValue` which expects the Header or Trailer string value.
52+
- Serializing is done via a common `toHttpValue` public method. The method returns the normalized string representation suited for HTTP textual representation
5353

5454
```php
5555
use Bakame\Http\StructuredFields\Dictionary;
@@ -66,15 +66,14 @@ $item = Item::fromHttpValue('"foo";a=1;b=2"');
6666
echo $item->toHttpValue(); // "foo";a=1;b=2
6767
```
6868

69-
The `toHttpValue` method returns the normalized string representation suited for HTTP textual representation.
70-
7169
## Structured Data Types
7270

7371
### Items
7472

7573
#### Types
7674

77-
Defined in the RFC, bare type are translated to PHP native type when possible. Two additional classes:
75+
Bare types defined in the RFC are translated to PHP
76+
native type when possible. Two additional classes:
7877

7978
- `Bakame\Http\StructuredFields\Token` and
8079
- `Bakame\Http\StructuredFields\ByteSequence`
@@ -92,9 +91,10 @@ are used to represent non-native types as shown in the table below:
9291

9392
#### Parameters
9493

95-
As explain in the RFC, `Parameters` are containers of `Item` instances. It can be associated
96-
to other structures **BUT** the items it contains can not themselves contain `Parameters`
97-
instance. More on parameters public API will be cover in subsequent paragraphs.
94+
As explain in the RFC, `Parameters` are containers of `Item` instances. They can be associated
95+
to an `Item` instance or other container types **BUT** the items it contains can not
96+
themselves contain `Parameters` instance. More on parameters public API
97+
will be cover in subsequent paragraphs.
9898

9999
#### Examples
100100

@@ -154,13 +154,13 @@ $parameters->hasKey(42); // return false because the key does not exist.
154154
$parameters->toHttpValue(); // return ";a=1;b=2"
155155
$parameters->keys(); // return ["a", "b", "c"]
156156
```
157-
*`getByIndex` supports use negative index*
158-
*Item types are inferred using `Item::from` if a `Item` object is not submitted.*
157+
- *`getByIndex` supports negative index*
158+
- *Item types are inferred using `Item::from` if a `Item` object is not submitted.*
159159

160160
#### Ordered Maps
161161

162-
The `Parameters` and the `Dictionary` classes allow associating a string key to its members as such they expose the
163-
following methods:
162+
The `Parameters` and the `Dictionary` classes allow associating a string
163+
key to its members as such they expose the following methods:
164164

165165
- `set` add an element at the end of the container if the key is new otherwise only the value is updated;
166166
- `append` always add an element at the end of the container, if already present the previous value is removed;
@@ -184,12 +184,13 @@ $dictionary->delete('b', 'c');
184184
echo $dictionary->toHttpValue(); //returns "a=?0, z=42.0"
185185
```
186186

187-
- `Parameters` can only contains `Item` instances whereas `Dictionary` instance can also contain lists.
187+
- `Parameters` can only contains `Item` instances
188+
- `Dictionary` instance can contain `Item` and `InnerList` instances.
188189

189190
#### Lists
190191

191-
The `OrderedList` and the `InnerList` classes are list of members that act as containers and also expose
192-
the following methods
192+
The `OrderedList` and the `InnerList` classes are list of members
193+
that act as containers and also expose the following methods
193194

194195
- `push` to add elements at the end of the list;
195196
- `unshift` to add elements at the beginning of the list;
@@ -212,7 +213,8 @@ $list->remove(0, 2);
212213
echo $list->toHttpValue(); //returns "("baz"), (), 42.0"
213214
```
214215

215-
The distinction between `InnerList` and `OrderedList` is well explained in the RFC but the main ones are:
216+
The distinction between `InnerList` and `OrderedList` is well explained in the
217+
RFC but the main ones are:
216218

217219
- `InnerList` members can be `Items` or `null`;
218220
- `OrderedList` members can be `InnerList`, `Items`;

0 commit comments

Comments
 (0)