File tree Expand file tree Collapse file tree 5 files changed +19
-4
lines changed Expand file tree Collapse file tree 5 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ All Notable changes to `bakame/http-strucured-fields` will be documented in this
13
13
- ` Item::toPair ` to complement ` Item::fromPair ` ;
14
14
- ` Item::fromDate ` to improve and complete the Item Date public API;
15
15
- ` Item::fromAssociative ` to improve Item public API;
16
+ - ` Item::fromString ` to improve Item public API;
16
17
- ` Value ` internal class to improve Item public API;
17
18
- ` Token::toString ` to return the string representation of the token.
18
19
Original file line number Diff line number Diff line change @@ -218,9 +218,10 @@ bare items (ie: item without parameters attached to them).
218
218
``` php
219
219
use Bakame\Http\StructuredFields\Item;
220
220
221
- Item::fromDecodedByteSequence(string $value): self;
222
- Item::fromEncodedByteSequence(string $value): self;
223
- Item::fromToken(string $value): self;
221
+ Item::fromDecodedByteSequence(Stringable|string $value): self;
222
+ Item::fromEncodedByteSequence(Stringable|string $value): self;
223
+ Item::fromToken(Stringable|string $value): self;
224
+ Item::fromString(Stringable|string $value): self;
224
225
Item::fromTimestamp(int $value): self;
225
226
Item::fromDateFormat(string $format, string $datetime): self;
226
227
Item::fromDateString(string $datetime, DateTimeZone|string|null $timezone = null): self;
Original file line number Diff line number Diff line change @@ -97,6 +97,14 @@ private static function fromValue(Value $value): self
97
97
return new self ($ value , Parameters::create ());
98
98
}
99
99
100
+ /**
101
+ * Returns a new instance from a string.
102
+ */
103
+ public static function fromString (Stringable |string $ value ): self
104
+ {
105
+ return self ::fromValue (Value::fromString ($ value ));
106
+ }
107
+
100
108
/**
101
109
* Returns a new instance from an encoded byte sequence and an iterable of key-value parameters.
102
110
*/
Original file line number Diff line number Diff line change @@ -243,7 +243,7 @@ public function it_instantiates_a_binary(): void
243
243
#[Test]
244
244
public function it_instantiates_a_string (): void
245
245
{
246
- self ::assertSame ('"foobar" ' , Item::fromAssociative ('foobar ' )->toHttpValue ());
246
+ self ::assertSame ('"foobar" ' , Item::fromString ('foobar ' )->toHttpValue ());
247
247
}
248
248
249
249
#[Test]
Original file line number Diff line number Diff line change @@ -182,6 +182,11 @@ public static function fromInteger(int|float $value): self
182
182
return new self ((int ) $ value );
183
183
}
184
184
185
+ public static function fromString (Stringable |string $ value ): self
186
+ {
187
+ return new self ($ value );
188
+ }
189
+
185
190
public static function true (): self
186
191
{
187
192
return new self (true );
You can’t perform that action at this time.
0 commit comments