@@ -53,7 +53,7 @@ private static function filterMember(mixed $member): object
53
53
/**
54
54
* Returns a new instance.
55
55
*/
56
- public static function from (ValueAccess |Token |ByteSequence |DateTimeInterface |Stringable |string |int |float |bool ...$ members ): self
56
+ public static function from (StructuredField |Token |ByteSequence |DateTimeInterface |Stringable |string |int |float |bool ...$ members ): self
57
57
{
58
58
return new self (Parameters::create (), $ members );
59
59
}
@@ -75,7 +75,7 @@ public static function fromPairs(
75
75
*/
76
76
public static function fromAssociative (
77
77
iterable $ parameters ,
78
- ValueAccess |Token |ByteSequence |DateTimeInterface |Stringable |string |int |float |bool ...$ members
78
+ StructuredField |Token |ByteSequence |DateTimeInterface |Stringable |string |int |float |bool ...$ members
79
79
): self {
80
80
return new self (Parameters::fromAssociative ($ parameters ), $ members );
81
81
}
@@ -97,47 +97,50 @@ public function parameters(): Parameters
97
97
return $ this ->parameters ;
98
98
}
99
99
100
- public function parameter (string $ key ): mixed
100
+ public function parameter (MapKey | string $ key ): mixed
101
101
{
102
+ $ key = $ key instanceof MapKey ? $ key ->value : $ key ;
102
103
if ($ this ->parameters ->has ($ key )) {
103
104
return $ this ->parameters ->get ($ key )->value ();
104
105
}
105
106
106
107
return null ;
107
108
}
108
109
109
- public function addParameter ( string $ key , StructuredField | Token | ByteSequence | DateTimeInterface | Stringable | string | int | float | bool $ member ): static
110
+ public function withParameters ( Parameters $ parameters ): static
110
111
{
111
- return $ this ->withParameters ($ this ->parameters ()->add ($ key , $ member ));
112
+ if ($ this ->parameters ->toHttpValue () === $ parameters ->toHttpValue ()) {
113
+ return $ this ;
114
+ }
115
+
116
+ return new static ($ parameters , $ this ->members );
112
117
}
113
118
114
- public function prependParameter ( string $ key , StructuredField |Token |ByteSequence |DateTimeInterface |Stringable |string |int |float |bool $ member ): static
119
+ public function addParameter ( MapKey | string $ key , StructuredField |Token |ByteSequence |DateTimeInterface |Stringable |string |int |float |bool $ member ): static
115
120
{
116
- return $ this ->withParameters ($ this ->parameters ()->prepend ( $ key , $ member ));
121
+ return $ this ->withParameters ($ this ->parameters ()->add ( $ key instanceof MapKey ? $ key -> value : $ key , $ member ));
117
122
}
118
123
119
- public function appendParameter ( string $ key , StructuredField |Token |ByteSequence |DateTimeInterface |Stringable |string |int |float |bool $ member ): static
124
+ public function prependParameter ( MapKey | string $ key , StructuredField |Token |ByteSequence |DateTimeInterface |Stringable |string |int |float |bool $ member ): static
120
125
{
121
- return $ this ->withParameters ($ this ->parameters ()->append ( $ key , $ member ));
126
+ return $ this ->withParameters ($ this ->parameters ()->prepend ( $ key instanceof MapKey ? $ key -> value : $ key , $ member ));
122
127
}
123
128
124
- public function withoutParameter ( string ... $ keys ): static
129
+ public function appendParameter ( MapKey | string $ key , StructuredField | Token | ByteSequence | DateTimeInterface | Stringable | string | int | float | bool $ member ): static
125
130
{
126
- return $ this ->withParameters ($ this ->parameters ()->remove (... $ keys ));
131
+ return $ this ->withParameters ($ this ->parameters ()->append ( $ key instanceof MapKey ? $ key -> value : $ key , $ member ));
127
132
}
128
133
129
- public function withoutAnyParameter ( ): static
134
+ public function withoutParameter ( MapKey | string ... $ keys ): static
130
135
{
131
- return $ this ->withParameters (Parameters::create ());
136
+ return $ this ->withParameters ($ this ->parameters ()->remove (
137
+ ...array_map (fn (MapKey |string $ key ): string => $ key instanceof MapKey ? $ key ->value : $ key , $ keys )
138
+ ));
132
139
}
133
140
134
- public function withParameters ( Parameters $ parameters ): static
141
+ public function withoutAnyParameter ( ): static
135
142
{
136
- if ($ this ->parameters ->toHttpValue () === $ parameters ->toHttpValue ()) {
137
- return $ this ;
138
- }
139
-
140
- return new static ($ parameters , $ this ->members );
143
+ return $ this ->withParameters (Parameters::create ());
141
144
}
142
145
143
146
public function toHttpValue (): string
0 commit comments