Skip to content

Commit 176f3cb

Browse files
committed
Improve Parser DX
1 parent dd745af commit 176f3cb

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ All Notable changes to `bakame/http-strucured-fields` will be documented in this
1414
- `Type::fromVariable`
1515
- `Type::tryFromVariable`
1616
- the `Type` enum is now a baked string Enum.
17+
- `Parser::new` to simplify parser usage.
1718

1819
### Fixed
1920

src/Parser.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ final class Parser implements DictionaryParser, InnerListParser, ItemParser, Lis
4545
private const FIRST_CHARACTER_RANGE_NUMBER = '-1234567890';
4646
private const FIRST_CHARACTER_RANGE_TOKEN = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*';
4747

48+
public static function new(): self
49+
{
50+
return new self();
51+
}
52+
4853
public function parseValue(Stringable|string $httpValue): ByteSequence|Token|DisplayString|DateTimeImmutable|string|int|float|bool
4954
{
5055
$remainder = trim((string) $httpValue, ' ');

0 commit comments

Comments
 (0)