Skip to content

Commit 701fcae

Browse files
committed
Improve type
1 parent 3234db4 commit 701fcae

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ All Notable changes to `bakame/http-strucured-fields` will be documented in this
77
### Added
88

99
- Support for `Stringable` instances added to `Item::from`, the instances will be converted to the string data type.
10-
- Support for the upcoming `Date` data type in `Item`. (see https://httpwg.org/http-extensions/draft-ietf-httpbis-sfbis.html)
11-
- date type is represented as a `DateTimeImmutable` object.
10+
- Support for the upcoming `Date` data type in `Item` represented as a `DateTimeImmutable` object. (see https://httpwg.org/http-extensions/draft-ietf-httpbis-sfbis.html)
1211
- `ParameterAccess` interface updated with new methods to ease parameter members modification.
1312
- `Parameter::create` named constructor to create a new instance without any parameter.
1413
- `Dictionnary::create` named constructor to create a new instance without any parameter.
15-
- `Type` Enum to list all possible Item Type supported.
14+
- `Type` Enum of all supported datatype.
1615
- `Value` Interface is introduced with `Item` being the only available implementation.
1716
- `MemberOrderedMap::add` and `MemberOrderedMap::remove` methods
1817
- `ByteSequence::equals` and `Token::equals` to easily compare type instances.
@@ -34,10 +33,10 @@ All Notable changes to `bakame/http-strucured-fields` will be documented in this
3433

3534
### Removed
3635

37-
- **[BC Break]** `ForbiddenStateError` exception is removed, the `InvalidArgument` exception is used instead.
38-
- **[BC Break]** `Item::is*` methods are removed, the enum `Type` is used instead.
39-
- **[BC Break]** `MemberContainer::clear` method is removed without replacement.
40-
- **[BC Break]** - `MemberOrderedMap::set` and `MemberOrderedMap::delete` methods; use `MemberOrderedMap::add` and `MemberOrderedMap::remove` instead
36+
- **[BC Break]** `ForbiddenStateError` exception is removed; the `InvalidArgument` exception is used instead.
37+
- **[BC Break]** `Item::is*` methods are removed; the enum `Type` is used instead.
38+
- **[BC Break]** `MemberContainer::clear` method is removed without replacement.
39+
- **[BC Break]** `MemberOrderedMap::set` and `MemberOrderedMap::delete` methods remonved; use `MemberOrderedMap::add` and `MemberOrderedMap::remove` instead
4140

4241
## [0.6.0] - 2022-11-12
4342

src/Type.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,9 @@ public static function fromValue(mixed $value): self
3333
default => throw new SyntaxError('The type "'.(is_object($value) ? $value::class : gettype($value)).'" is not supported.'),
3434
};
3535
}
36+
37+
public function equals(mixed $other): bool
38+
{
39+
return $other instanceof self && $other === $this;
40+
}
3641
}

src/TypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function it_will_throw_if_the_type_is_no_supported(): void
2525
*/
2626
public function it_can_tell_the_item_type(mixed $value, Type $expectedType): void
2727
{
28-
self::assertSame($expectedType, Type::fromValue($value));
28+
self::assertTrue($expectedType->equals(Type::fromValue($value)));
2929
}
3030

3131
/**

0 commit comments

Comments
 (0)