File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 2121
2222final class Filter
2323{
24+ /**
25+ * @var string
26+ */
27+ private const MESSAGE = 'Expected a bool return type on callable filter, %s given ' ;
28+
2429 public static function boolean (callable $ filter ): void
2530 {
2631 if ($ filter instanceof Closure) {
@@ -43,7 +48,7 @@ public static function boolean(callable $filter): void
4348
4449 throw new InvalidArgumentException (
4550 sprintf (
46- ' Expected a bool return type on callable filter, %s given ' ,
51+ self :: MESSAGE ,
4752 implode ($ separator , array_map (
4853 static fn (ReflectionNamedType $ reflectionNamedType ): string => $ reflectionNamedType ->getName (),
4954 $ types
@@ -53,13 +58,13 @@ public static function boolean(callable $filter): void
5358 }
5459
5560 if (! $ returnType instanceof ReflectionNamedType) {
56- throw new InvalidArgumentException (' Expected a bool return type on callable filter, mixed given ' );
61+ throw new InvalidArgumentException (sprintf ( self :: MESSAGE , ' mixed ' ) );
5762 }
5863
5964 $ returnTypeName = $ returnType ->getName ();
6065 if ($ returnTypeName !== 'bool ' ) {
6166 throw new InvalidArgumentException (sprintf (
62- ' Expected a bool return type on callable filter, %s given ' ,
67+ self :: MESSAGE ,
6368 $ returnTypeName
6469 ));
6570 }
You can’t perform that action at this time.
0 commit comments