File tree Expand file tree Collapse file tree 2 files changed +14
-16
lines changed Expand file tree Collapse file tree 2 files changed +14
-16
lines changed Original file line number Diff line number Diff line change 42
42
"php" : " ^8.1"
43
43
},
44
44
"require-dev" : {
45
- "friendsofphp/php-cs-fixer" : " ^3.64 .0" ,
45
+ "friendsofphp/php-cs-fixer" : " ^3.65 .0" ,
46
46
"httpwg/structured-field-tests" : " *@dev" ,
47
- "phpstan/phpstan" : " ^1.12.8 " ,
47
+ "phpstan/phpstan" : " ^1.12.12 " ,
48
48
"phpstan/phpstan-strict-rules" : " ^1.6.1" ,
49
- "phpstan/phpstan-phpunit" : " ^1.4.0 " ,
49
+ "phpstan/phpstan-phpunit" : " ^1.4.1 " ,
50
50
"phpstan/phpstan-deprecation-rules" : " ^1.2.1" ,
51
- "phpunit/phpunit" : " ^10.5.15 || ^11.4.3 " ,
51
+ "phpunit/phpunit" : " ^10.5.15 || ^11.4.4 " ,
52
52
"phpbench/phpbench" : " ^1.3.1" ,
53
- "symfony/var-dumper" : " ^6.4.14 " ,
53
+ "symfony/var-dumper" : " ^6.4.15 " ,
54
54
"bakame/aide-base32" : " dev-main"
55
55
},
56
56
"autoload" : {
Original file line number Diff line number Diff line change 2
2
3
3
namespace Bakame \Http \StructuredFields ;
4
4
5
+ use Stringable ;
6
+
5
7
use function preg_match ;
6
8
7
9
/**
10
12
*/
11
13
final class MapKey
12
14
{
13
- private function __construct (
14
- public readonly string $ value
15
- ) {
15
+ private function __construct (public readonly string $ value )
16
+ {
16
17
}
17
18
18
19
/**
19
20
* @throws SyntaxError If the string is not a valid HTTP value field key
20
21
*/
21
- public static function from (string |int $ httpValue ): self
22
+ public static function from (Stringable | string |int $ httpValue ): self
22
23
{
23
- if (!is_string ($ httpValue )) {
24
- throw new SyntaxError ('The key must be a string; ' .gettype ($ httpValue ).' received. ' );
25
- }
26
-
27
- $ instance = self ::fromStringBeginning ($ httpValue );
28
- if ($ instance ->value !== $ httpValue ) {
24
+ $ key = (string ) $ httpValue ;
25
+ $ instance = self ::fromStringBeginning ($ key );
26
+ if ($ instance ->value !== $ key ) {
29
27
throw new SyntaxError ('No valid http value key could be extracted from " ' .$ httpValue .'". ' );
30
28
}
31
29
32
30
return $ instance ;
33
31
}
34
32
35
- public static function tryFrom (string |int $ httpValue ): ?self
33
+ public static function tryFrom (Stringable | string |int $ httpValue ): ?self
36
34
{
37
35
try {
38
36
return self ::from ($ httpValue );
You can’t perform that action at this time.
0 commit comments