File tree Expand file tree Collapse file tree 5 files changed +31
-15
lines changed Expand file tree Collapse file tree 5 files changed +31
-15
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
3
All Notable changes to ` bakame/http-strucured-fields ` will be documented in this file
4
+
5
+ ## [ Next] - TBD
6
+
7
+ ### Added
8
+
9
+ - None
10
+
11
+ ### Fixed
12
+
13
+ - ** [ BC Break] ** ` Item::value ` method returns the Item (returns value can be ` float|int|string|bool|ByteSequence|Token ` ).
14
+
15
+ ### Deprecated
16
+
17
+ - None
18
+
19
+ ### Removed
20
+
21
+ - None
4
22
5
23
## [ 0.6.0] - 2022-11-12
6
24
Original file line number Diff line number Diff line change @@ -98,8 +98,8 @@ $item = StructuredFields\Item::fromPair([
98
98
$item->value(); // returns "hello world"
99
99
$item->isString(); // returns true
100
100
$item->parameters()["a"]->isByteSequence(); // returns true
101
- $item->parameters()["a"]->value(); // returns the decoded value 'Hello World'
102
- echo $item->toHttpValue(); // returns "hello world";a=:SGVsbG8gV29ybGQ=:
101
+ $item->parameters()["a"]->value(); // returns StructuredFields\ByteSequence::fromDecoded( 'Hello World');
102
+ echo $item->toHttpValue(); // returns "hello world";a=:SGVsbG8gV29ybGQ=:
103
103
```
104
104
105
105
` Item::fromPair ` is an alternative to the ` Item::from ` named constructor, it expects
@@ -117,9 +117,9 @@ Once instantiated, accessing `Item` properties is done via:
117
117
``` php
118
118
use Bakame\Http\StructuredFields;
119
119
120
- $item = StructuredFields\Item::from(StructuredFields\ByteSequence::fromEncoded("SGVsbG8gV29ybGQ=")] );
120
+ $item = StructuredFields\Item::from(StructuredFields\ByteSequence::fromEncoded("SGVsbG8gV29ybGQ="));
121
121
$item->isByteSequence(); // returns true
122
- echo $item->value(); // returns the decoded value 'Hello World'
122
+ echo $item->value(); // returns StructuredFields\ByteSequence::fromEncoded("SGVsbG8gV29ybGQ=");
123
123
```
124
124
125
125
** Of note: to instantiate a decimal number type a float MUST be used as the first argument of ` Item::from ` .**
Original file line number Diff line number Diff line change @@ -130,7 +130,7 @@ public function it_successfully_parse_a_http_field(): void
130
130
self ::assertSame ('hello)world ' , $ instance ->get (0 )->value ());
131
131
self ::assertSame (42 , $ instance ->get (1 )->value ());
132
132
self ::assertSame (42.0 , $ instance ->get (2 )->value ());
133
- self ::assertSame ( 'doe ' , $ instance ->get (2 )->parameters ()['john ' ]->value ());
133
+ self ::assertEquals (Token:: fromString ( 'doe ' ) , $ instance ->get (2 )->parameters ()['john ' ]->value ());
134
134
}
135
135
136
136
/** @test */
@@ -194,7 +194,7 @@ public function it_can_access_the_item_value(): void
194
194
$ structuredField = InnerList::fromList ($ input );
195
195
196
196
self ::assertFalse ($ structuredField [2 ]->value ());
197
- self ::assertSame ( ' token ' , $ structuredField [-1 ]->value ());
197
+ self ::assertEquals ( $ token , $ structuredField [-1 ]->value ());
198
198
}
199
199
200
200
/** @test */
Original file line number Diff line number Diff line change @@ -290,13 +290,9 @@ private function serializeDecimal(float $value): string
290
290
/**
291
291
* Returns the underlying value decoded.
292
292
*/
293
- public function value (): string | int |float |bool
293
+ public function value (): Token | ByteSequence | int |float | string |bool
294
294
{
295
- return match (true ) {
296
- $ this ->value instanceof Token => $ this ->value ->value ,
297
- $ this ->value instanceof ByteSequence => $ this ->value ->decoded (),
298
- default => $ this ->value ,
299
- };
295
+ return $ this ->value ;
300
296
}
301
297
302
298
public function withValue (Token |ByteSequence |int |float |string |bool $ value ): self
Original file line number Diff line number Diff line change @@ -81,9 +81,11 @@ public function it_instantiates_a_token(): void
81
81
/** @test */
82
82
public function it_instantiates_a_binary (): void
83
83
{
84
- self ::assertSame ('foobar ' , Item::from (ByteSequence::fromDecoded ('foobar ' ))->value ());
85
- self ::assertSame ('foobar ' , Item::fromDecodedByteSequence ('foobar ' )->value ());
86
- self ::assertSame ('foobar ' , Item::fromEncodedByteSequence ('Zm9vYmFy ' )->value ());
84
+ $ byteSequence = ByteSequence::fromDecoded ('foobar ' );
85
+
86
+ self ::assertEquals ($ byteSequence , Item::from (ByteSequence::fromDecoded ('foobar ' ))->value ());
87
+ self ::assertEquals ($ byteSequence , Item::fromDecodedByteSequence ('foobar ' )->value ());
88
+ self ::assertEquals ($ byteSequence , Item::fromEncodedByteSequence ('Zm9vYmFy ' )->value ());
87
89
}
88
90
89
91
/** @test */
You can’t perform that action at this time.
0 commit comments