Skip to content

Commit 2d41ebb

Browse files
committed
Remove interfaces and add convenients methods
1 parent 62ed006 commit 2d41ebb

29 files changed

+577
-691
lines changed

.php-cs-fixer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
4+
35
$finder = PhpCsFixer\Finder::create()
46
->in(__DIR__.'/src')
57
->in(__DIR__.'/tests')
@@ -8,6 +10,7 @@
810
$config = new PhpCsFixer\Config();
911

1012
return $config
13+
->setParallelConfig(ParallelConfigFactory::detect())
1114
->setRules([
1215
'@PSR12' => true,
1316
'array_syntax' => ['syntax' => 'short'],

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@ All Notable changes to `bakame/http-strucured-fields` will be documented in this
88

99
- `Ietf` enum.
1010
- methods `fromRFC9651`, `fromRfc8941`, `toRFC9651`, `toRfc8941`, to ease Type and StructuredFields convertion between RFC.
11+
- methods `map`, `reduce`, `filter`, `sort` to `all containers classes.
12+
- `StructuredFieldProvider` interface
1113

1214
### Fixed
1315

14-
- None
16+
- Removed the `Parser` from the public API.
17+
- Fixed `Tyoe` inference when instantiating the `Value` class.
1518

1619
### Deprecated
1720

1821
- None
1922

2023
### Removed
2124

22-
- None
25+
- `MemberContainer`, `MemberList`, `MemberOrderedMap`, and all the Parser related methods.
2326

2427
## [1.3.0](https://github.com/bakame-php/http-structured-fields/compare/1.2.2...1.3.0) - 2024-01-05
2528

src/DataType.php

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,33 +33,31 @@ public function fromRfc8941(Stringable|string $httpValue): StructuredField
3333
/**
3434
* @throws StructuredFieldError
3535
*/
36-
public function toRfc9651(iterable $data): string
36+
public function parse(Stringable|string $httpValue, ?Ietf $rfc = null): StructuredField
3737
{
38-
return $this->serialize($data, Ietf::Rfc9651);
38+
return match ($this) {
39+
self::List => OuterList::fromHttpValue($httpValue, $rfc),
40+
self::InnerList => InnerList::fromHttpValue($httpValue, $rfc),
41+
self::Parameters => Parameters::fromHttpValue($httpValue, $rfc),
42+
self::Dictionary => Dictionary::fromHttpValue($httpValue, $rfc),
43+
self::Item => Item::fromHttpValue($httpValue, $rfc),
44+
};
3945
}
4046

4147
/**
4248
* @throws StructuredFieldError
4349
*/
44-
public function toRfc8941(iterable $data): string
50+
public function toRfc9651(iterable $data): string
4551
{
46-
return $this->serialize($data, Ietf::Rfc8941);
52+
return $this->serialize($data, Ietf::Rfc9651);
4753
}
4854

4955
/**
5056
* @throws StructuredFieldError
5157
*/
52-
public function parse(Stringable|string $httpValue, ?Ietf $rfc = null): StructuredField
58+
public function toRfc8941(iterable $data): string
5359
{
54-
$parser = new Parser($rfc);
55-
56-
return match ($this) {
57-
self::List => OuterList::fromHttpValue($httpValue, $parser),
58-
self::InnerList => InnerList::fromHttpValue($httpValue, $parser),
59-
self::Parameters => Parameters::fromHttpValue($httpValue, $parser),
60-
self::Dictionary => Dictionary::fromHttpValue($httpValue, $parser),
61-
self::Item => Item::fromHttpValue($httpValue, $parser),
62-
};
60+
return $this->serialize($data, Ietf::Rfc8941);
6361
}
6462

6563
/**
@@ -83,17 +81,4 @@ public function create(iterable $data): StructuredField
8381
self::Item => Item::fromPair([...$data]), /* @phpstan-ignore-line */
8482
};
8583
}
86-
87-
/**
88-
* DEPRECATION WARNING! This method will be removed in the next major point release.
89-
*
90-
* @deprecated Since version 1.3.0
91-
* @codeCoverageIgnore
92-
*
93-
* @see DataType::serialize()
94-
*/
95-
public function build(iterable $data, ?Ietf $rfc = null): string
96-
{
97-
return $this->serialize($data, $rfc);
98-
}
9984
}

0 commit comments

Comments
 (0)