From 1425e79e5d8bfb1d93af0b9bf0744860cc572a67 Mon Sep 17 00:00:00 2001 From: Ignace Nyamagana Butera Date: Mon, 2 Dec 2024 11:30:50 +0100 Subject: [PATCH] Sync implementation with http-structured-field package update --- src/Properties.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Properties.php b/src/Properties.php index 97c7392..2e670f0 100644 --- a/src/Properties.php +++ b/src/Properties.php @@ -8,7 +8,7 @@ use Bakame\Http\StructuredFields\Validation\ParametersValidator; /** - * @phpstan-import-type SfParameterNameRule from ParametersValidator + * @phpstan-import-type SfParameterKeyRule from ParametersValidator */ enum Properties: string { @@ -27,7 +27,7 @@ public static function validator(): ParametersValidator static $validator; if (null === $validator) { - /** @var array $filters */ + /** @var array $filters */ $filters = array_reduce( self::cases(), fn (array $rules, self $property): array => [...$rules, ...[$property->value => $property->validate()]], @@ -36,12 +36,12 @@ public static function validator(): ParametersValidator $validator = ParametersValidator::new() ->filterByCriteria(function (Parameters $parameters): bool|string { - if (!$parameters->allowedNames(array_map(fn (self $case) => $case->value, self::cases()))) { + if (!$parameters->allowedKeys(array_map(fn (self $case) => $case->value, self::cases()))) { return 'The cache contains invalid parameters.'; } - $hit = !in_array($parameters->valueByName(self::Hit->value, default: false), [null, false], true); - $fwd = $parameters->valueByName(self::Forward->value); + $hit = !in_array($parameters->valueByKey(self::Hit->value, default: false), [null, false], true); + $fwd = $parameters->valueByKey(self::Forward->value); return match (true) { !$hit && null !== $fwd, @@ -49,14 +49,14 @@ public static function validator(): ParametersValidator default => "The '".self::Hit->value."' and '".self::Forward->value."' parameters are mutually exclusive.", }; }) - ->filterByNames($filters); + ->filterByKeys($filters); } return $validator; } /** - * @return SfParameterNameRule + * @return SfParameterKeyRule */ public function validate(): array {