Skip to content

Commit 6a99128

Browse files
committed
Update documentation v2
1 parent 56da217 commit 6a99128

File tree

4 files changed

+26
-32
lines changed

4 files changed

+26
-32
lines changed

docs/05-containers.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ with the changes applied and leave the original instance unchanged.
100100

101101
### Ordered Maps
102102

103-
The `Dictionary` and `Parameters` are ordered map instances. They can be built using their keys with an
103+
The `Dictionary` and `Parameters` are ordered map instances. They can be built using their names with an
104104
associative iterable structure as shown below
105105

106106
```php
@@ -142,7 +142,7 @@ $map->add(string $name, $value): static;
142142
$map->append(string $name, $value): static;
143143
$map->prepend(string $name, $value): static;
144144
$map->mergeAssociative(...$others): static;
145-
$map->removeByKeys(string ...$names): static;
145+
$map->removeByNames(string ...$names): static;
146146
```
147147

148148
As shown below:
@@ -210,17 +210,17 @@ echo $value; //b=?0, a=(bar "42" 42 42.0), c=@1671800423
210210
```
211211

212212
> [!CAUTION]
213-
> on duplicate `keys` pair values are merged as per RFC logic.
213+
> on duplicate `names` pair values are merged as per RFC logic.
214214
215-
The following methods `removeByIndices` and/or `removeByKeys` allow removing members
216-
per indices or per keys.
215+
The following methods `removeByIndices` and/or `removeByNames` allow removing members
216+
per indices or per names.
217217

218218
```php
219219
use Bakame\Http\StructuredFields\Parameters;
220220

221221
$field = Parameters::fromHttpValue(';expire=@1681504328;path="/";max-age=2500;secure;httponly=?0;samesite=lax');
222222
echo $field->removeByIndices(4, 2, 0)->toHttpValue(); // returns ;path="/";secure;samesite=lax
223-
echo $field->removeByKeys('expire', 'httponly', 'max-age')->toHttpValue(); // returns ;path="/";secure;samesite=lax
223+
echo $field->removeByNames('expire', 'httponly', 'max-age')->toHttpValue(); // returns ;path="/";secure;samesite=lax
224224
```
225225

226226
### Automatic conversion
@@ -387,14 +387,14 @@ You can attach and update the associated `Parameters` instance using the followi
387387
$field->addParameter(string $name, mixed $value): static;
388388
$field->appendParameter(string $name, mixed $value): static;
389389
$field->prependParameter(string $name, mixed $value): static;
390-
$field->withoutParameters(string ...$keys): static; // this method is deprecated as of version 1.1 use withoutParametersByKeys instead
390+
$field->withoutParameters(string ...$names): static; // this method is deprecated as of version 1.1 use withoutParametersByKeys instead
391391
$field->withoutAnyParameter(): static;
392392
$field->withParameters(Parameters $parameters): static;
393393
$field->pushParameters(array ...$pairs): static
394394
$field->unshiftParameters(array ...$pairs): static
395395
$field->insertParameters(int $index, array ...$pairs): static
396396
$field->replaceParameter(int $index, array $pair): static
397-
$field->withoutParametersByKeys(string ...$keys): static
397+
$field->withoutParametersByNames(string ...$names): static
398398
$field->withoutParametersByIndices(int ...$indices): static
399399
```
400400

docs/06-validation.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,26 +137,26 @@ $value = $member
137137
138138
### Validating the Item parameters.
139139

140-
### Checking for allowed keys
140+
### Checking for allowed names
141141

142142
Before validating the content of the `Parameters` container we need to make
143-
sure the container contains the proper data. That all the allowed keys are
144-
present. To do so we can use the `Parameters::allowedKeys` method. This
145-
method expects a list of keys. If other keys not present in the
143+
sure the container contains the proper data. That all the allowed names are
144+
present. To do so we can use the `Parameters::allowedNames` method. This
145+
method expects a list of names. If other names not present in the
146146
list are found in the container the method will return `false`. If we
147-
go back to our definition. We know that the allowed parameters keys attached
147+
go back to our definition. We know that the allowed parameters names attached
148148
to the item are: `location`, `longitude`, `latitude` and `date`
149149

150150
```php
151151
use Bakame\Http\StructuredFields\Validation\Violation;
152152

153-
if (!$member->parameters()->allowedKeys(['location', 'longitude', 'latitude', 'date'])) {
154-
throw new Violation('The parameters contains extra keys that are not allowed.');
153+
if (!$member->parameters()->allowedNames(['location', 'longitude', 'latitude', 'date'])) {
154+
throw new Violation('The parameters contains extra names that are not allowed.');
155155
}
156156
```
157157

158158
> [!TIP]
159-
> The `Dictionary` class also exposes an `allowedKeys` method which behave the same way.
159+
> The `Dictionary` class also exposes an `allowedNames` method which behave the same way.
160160
161161
> [!WARNING]
162162
> if the parameters container is empty no error will be triggered
@@ -208,13 +208,13 @@ all the criteria.
208208
Going back to the HTTP field definitions we can translate the requirements and create the
209209
following `ParametersValidator`.
210210

211-
We need to make sure about the allowed keys for that. the class has a `filterByCriteria` which
211+
We need to make sure about the allowed names for that. the class has a `filterByCriteria` which
212212
expects the `Parameters` container as its sole argument.
213213

214214
```php
215215
$parametersValidator = ParametersValidator::new()
216216
->filterByCriteria(function (Parameters $parameters): bool|string {
217-
return $parameters->allowedKeys(['location', 'longitude', 'latitude', 'date']);
217+
return $parameters->allowedNames(['location', 'longitude', 'latitude', 'date']);
218218
});
219219
```
220220

@@ -228,7 +228,7 @@ we did earlier we end up with the following entries.
228228
```php
229229
use Bakame\Http\StructuredFields\Type;
230230

231-
$parametersValidator = ->filterByKeys([
231+
$parametersValidator = ->filterByNames([
232232
'longitude' => [
233233
'validate' => function (mixed $value) {
234234
if (!Type::Decimal->supports($value)) {
@@ -242,7 +242,7 @@ $parametersValidator = ->filterByKeys([
242242
]);
243243
```
244244

245-
We can do the same for all the other keys, the available parameters are:
245+
We can do the same for all the other names, the available parameters are:
246246
- `validate`: the callback used for validation; `null` by default
247247
- `required`: a boolean telling whether the parameter presence is required; `false` by default
248248
- `default`: the default value if the parameter is optional; `null` by default.
@@ -329,7 +329,7 @@ if ($validation->isSucces()) {
329329
> [!NOTE]
330330
> If we only use the `filterByCriteria` method the full parameter data is returned.
331331
332-
A `filterByIndices` method exists and behave exactly as the `filterByKeys` method.
332+
A `filterByIndices` method exists and behave exactly as the `filterByNames` method.
333333
There are two differences when it is used:
334334

335335
- The callback parameters are different (they match those of `parameterByIndex`)

docs/07-extensions.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,8 @@ echo $container; // returns '(:SGVsbG8gV29ybGQ=: 42.0 42)'
2323
As a rule of thumb all the classes from this package are final and immutable and
2424
expose no particular interface.
2525

26-
> [!IMPORTANT]
27-
> The `StructuredField` interface should be seen as an internal implementation detail
28-
> and should not be implemented outside the package. While PHP does not prohibit such
29-
> action, **you MUST NOT implement the `StructuredField` interface.**
30-
31-
The reason for disallowing the `StructuredField` interface is simple. We want to ensure
32-
that in any situation the RFC is being respected. The contract is between the RFC and your
33-
code the package only acts as a link between both parties.
26+
The reason is to ensure that in any situation the RFC is being respected. The contract
27+
is between the RFC and your code the package only acts as a link between both parties.
3428

3529
## Closed for extension opened for composition
3630

@@ -49,8 +43,8 @@ interface StructuredFieldProvider
4943
This interface should return one of the DataType class and this is the interface that needs
5044
to be implemented. All the containers are able to work with a `StructuredFieldProvider`.
5145

52-
Imagine you have an `AcceptHeaderItem` class and you want to take advantage of the package. You
53-
only have to implemente the `StructuredFieldProvider`. Once done, your class will be able to
46+
Imagine you have an `AcceptHeaderItem` class, and you want to take advantage of the package. You
47+
only have to implement the `StructuredFieldProvider`. Once done, your class will be able to
5448
work with the `OuterList` class.
5549

5650
```php

src/Item.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static function fromRfc8941(Stringable|string $httpValue): self
4343

4444
/**
4545
* Returns a new instance from an HTTP Header or Trailer value string
46-
* in compliance with RFC8941.
46+
* in compliance with a published RFC.
4747
*
4848
* @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.3
4949
*

0 commit comments

Comments
 (0)