Skip to content

Commit 02e708e

Browse files
committed
Add isFilterBoolean method
1 parent 7b3465d commit 02e708e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/ApiPlatform/State/Base/Wrapper/BaseResourceWrapperProvider.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ protected function getUriVariablesOutput(): array
374374
$property[BaseRoute::KEY_TYPE] === BaseRoute::TYPE_STRING,
375375
$property[BaseRoute::KEY_TYPE] === BaseRoute::TYPE_ENUM_STRING => $this->getFilterString($name),
376376
$property[BaseRoute::KEY_TYPE] === BaseRoute::TYPE_INTEGER => $this->getFilterInteger($name),
377+
$property[BaseRoute::KEY_TYPE] === BaseRoute::TYPE_BOOLEAN => $this->isFilterBoolean($name),
377378
default => throw new TypeInvalidException(sprintf('BaseRoute::KEY_TYPE (%s)', $name)),
378379
};
379380
break;
@@ -552,6 +553,19 @@ protected function getFilterInteger(string $name): int
552553
return (new TypeCastingHelper($this->getFilter($name)))->intval();
553554
}
554555

556+
/**
557+
* Returns a filter variable as bool representation.
558+
*
559+
* @param string $name
560+
* @return bool
561+
* @throws ArrayKeyNotFoundException
562+
* @throws TypeInvalidException
563+
*/
564+
protected function isFilterBoolean(string $name): bool
565+
{
566+
return (bool) $this->getFilter($name);
567+
}
568+
555569
/**
556570
* @return array<int|string, mixed>|null
557571
*/

0 commit comments

Comments
 (0)