From 47b8e5316e87935c06e9ae0e5f0c63f7549b6b30 Mon Sep 17 00:00:00 2001 From: bbprojectnet Date: Fri, 16 Jul 2021 13:37:39 +0200 Subject: [PATCH] [Feature] Allow null value for has-delimeter filter (#14) Co-authored-by: M@ster --- src/Filters/Concerns/HasDelimiter.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Filters/Concerns/HasDelimiter.php b/src/Filters/Concerns/HasDelimiter.php index 019cf34..1cf1f8c 100644 --- a/src/Filters/Concerns/HasDelimiter.php +++ b/src/Filters/Concerns/HasDelimiter.php @@ -47,7 +47,7 @@ public function delimiter(string $delimiter): self /** * Convert the provided value to an array. * - * @param string|array $value + * @param string|array|null $value * @return array */ protected function toArray($value): array @@ -60,6 +60,10 @@ protected function toArray($value): array return $value; } + if (\is_null($value)) { + return []; + } + throw new \LogicException( 'Expecting filter value to be an array, or a string when a string delimiter is set.' );