@@ -48,7 +48,7 @@ $permissions->isEmpty(); // returns false
48
48
49
49
> [ !IMPORTANT]
50
50
> For ordered maps, the ` getByIndex ` method returns a list containing exactly 2 entries.
51
- > The first entry is the member name , the second entry is the member value.
51
+ > The first entry is the member key , the second entry is the member value.
52
52
> For lists, the method directly returns the value.
53
53
54
54
To avoid invalid states, ` ArrayAccess ` modifying methods throw a ` ForbiddenOperation `
@@ -68,39 +68,39 @@ unset($permissions['a']); // triggers a ForbiddenOperation exception
68
68
The ` Dictionary ` and ` Parameters ` classes also allow accessing their members as value using their name:
69
69
70
70
``` php
71
- $permissions->hasName ('picture-in-picture'); // returns true
72
- $permissions->hasName ('picture-in-picture', 'foobar'); // returns false
71
+ $permissions->hasKey ('picture-in-picture'); // returns true
72
+ $permissions->hasKey ('picture-in-picture', 'foobar'); // returns false
73
73
// 'foobar' is not a valid name or at least it is not present
74
74
75
- $permissions->getByName ('camera'); // returns Item::fromToken('*');
75
+ $permissions->getByKey ('camera'); // returns Item::fromToken('*');
76
76
$permissions->toAssociative(); // returns an iterator
77
77
// the iterator key is the member name and the value is the member value
78
78
// the offset is "lost"
79
- $permissions->nameByIndex (42); // returns null because there's no member with the offset 42
80
- $permissions->nameByIndex (2); // returns 'camera'
79
+ $permissions->keyByIndex (42); // returns null because there's no member with the offset 42
80
+ $permissions->keyByIndex (2); // returns 'camera'
81
81
82
- $permissions->indexByName ('foobar'): // returns null because there's no member with the name 'foobar'
83
- $permissions->indexByName ('geolocation'): // returns 1
82
+ $permissions->indexByKey ('foobar'): // returns null because there's no member with the name 'foobar'
83
+ $permissions->indexByKey ('geolocation'): // returns 1
84
84
```
85
85
86
86
> [ !IMPORTANT]
87
- > The ` getByName ` method will throw an ` InvalidOffset ` exception if no member exists for the given ` $offset ` .
87
+ > The ` getByKey ` method will throw an ` InvalidOffset ` exception if no member exists for the given ` $offset ` .
88
88
89
89
> [ !TIP]
90
90
> The ` ArrayAccess ` interface proxy the result from ` getByIndex ` and ` hasIndices ` with ` OuterList ` and ` InnerList ` .
91
- > The ` ArrayAccess ` interface proxy the result from ` getByName ` and ` hasNames ` with ` Dictionary ` and ` Parameters ` .
91
+ > The ` ArrayAccess ` interface proxy the result from ` getByNKey ` and ` hasKeys ` with ` Dictionary ` and ` Parameters ` .
92
92
93
93
### Accessing the parameters values
94
94
95
95
As we have already seen, it is possible to access the ` Parameters ` values directly
96
96
from the ` Item ` instance. The same public API is used for the ` InnerList ` .
97
97
98
98
On the other hand if you already have a ` Parameters ` instance you can use the
99
- ` valueByName ` and ` valueByIndex ` methods to directly access the value from a single
99
+ ` valueByKey ` and ` valueByIndex ` methods to directly access the value from a single
100
100
parameter.
101
101
102
102
> [ !TIP]
103
- > The ` parameterByName ` proxy the result from ` valueByName ` .
103
+ > The ` parameterByKey ` proxy the result from ` valueByKey ` .
104
104
> The ` parameterByIndex ` proxy the result from ` valueByIndex ` .
105
105
106
106
## Building and Updating Containers
@@ -149,11 +149,11 @@ following steps. You, first, create a `Parameters` or a `Dictionary` instance us
149
149
use any of the following modifying methods to populate it.
150
150
151
151
``` php
152
- $map->add(string $name , $value): static;
153
- $map->append(string $name , $value): static;
154
- $map->prepend(string $name , $value): static;
152
+ $map->add(string $key , $value): static;
153
+ $map->append(string $key , $value): static;
154
+ $map->prepend(string $key , $value): static;
155
155
$map->mergeAssociative(...$others): static;
156
- $map->removeByNames (string ...$names ): static;
156
+ $map->removeByKeys (string ...$keys ): static;
157
157
```
158
158
159
159
As shown below:
@@ -183,14 +183,14 @@ using indices and pair as described in the RFC.
183
183
184
184
The ` $pair ` parameter is a tuple (ie: an array as list with exactly two members) where:
185
185
186
- - the first array member is the parameter ` $name `
186
+ - the first array member is the parameter ` $key `
187
187
- the second array member is the parameter ` $value `
188
188
189
189
``` php
190
190
$map->unshift(array ...$pairs): static;
191
191
$map->push(array ...$pairs): static;
192
- $map->insert(int $name , array ...$pairs): static;
193
- $map->replace(int $name , array $pair): static;
192
+ $map->insert(int $index , array ...$pairs): static;
193
+ $map->replace(int $index , array $pair): static;
194
194
$map->mergePairs(...$others): static;
195
195
$map->removeByIndices(int ...$indices): static;
196
196
```
@@ -223,15 +223,15 @@ echo $value; //b=?0, a=(bar "42" 42 42.0), c=@1671800423
223
223
> [ !CAUTION]
224
224
> on duplicate ` names ` pair values are merged as per RFC logic.
225
225
226
- The following methods ` removeByIndices ` and/or ` removeByNames ` allow removing members
226
+ The following methods ` removeByIndices ` and/or ` removeByKeys ` allow removing members
227
227
per indices or per names.
228
228
229
229
``` php
230
230
use Bakame\Http\StructuredFields\Parameters;
231
231
232
232
$field = Parameters::fromHttpValue(';expire=@1681504328;path="/";max-age=2500;secure;httponly=?0;samesite=lax');
233
233
echo $field->removeByIndices(4, 2, 0)->toHttpValue(); // returns ;path="/";secure;samesite=lax
234
- echo $field->removeByNames ('expire', 'httponly', 'max-age')->toHttpValue(); // returns ;path="/";secure;samesite=lax
234
+ echo $field->removeByKeys ('expire', 'httponly', 'max-age')->toHttpValue(); // returns ;path="/";secure;samesite=lax
235
235
```
236
236
237
237
### Automatic conversion
@@ -396,21 +396,21 @@ You can attach and update the associated `Parameters` instance using the followi
396
396
397
397
``` php
398
398
$field->withParameters(Parameters $parameters): static;
399
- $field->addParameter(string $name , mixed $value): static;
400
- $field->appendParameter(string $name , mixed $value): static;
401
- $field->prependParameter(string $name , mixed $value): static;
399
+ $field->addParameter(string $key , mixed $value): static;
400
+ $field->appendParameter(string $key , mixed $value): static;
401
+ $field->prependParameter(string $key , mixed $value): static;
402
402
$field->pushParameters(array ...$pairs): static
403
403
$field->unshiftParameters(array ...$pairs): static
404
404
$field->insertParameters(int $index, array ...$pairs): static
405
405
$field->replaceParameter(int $index, array $pair): static
406
- $field->withoutParametersByNames (string ...$names ): static
406
+ $field->withoutParametersByKeys (string ...$keys ): static
407
407
$field->withoutParametersByIndices(int ...$indices): static
408
408
$field->withoutAnyParameter(): static;
409
409
```
410
410
411
411
The ` $pair ` parameter is an array as list with exactly two members where:
412
412
413
- - the first array member is the parameter ` $name `
413
+ - the first array member is the parameter ` $key `
414
414
- the second array member is the parameter ` $value `
415
415
416
416
> [ !WARNING]
0 commit comments