File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 4
4
5
5
namespace KaririCode \Sanitizer \Exception ;
6
6
7
- final class SanitizationException extends \RuntimeException
7
+ use KaririCode \Exception \AbstractException ;
8
+
9
+ final class SanitizationException extends AbstractException
8
10
{
11
+ private const CODE_INVALID_INPUT = 4001 ;
12
+
13
+ public static function invalidInput (string $ expectedType ): self
14
+ {
15
+ $ message = sprintf (
16
+ 'Input must be a %s ' ,
17
+ $ expectedType
18
+ );
19
+
20
+ return self ::createException (
21
+ self ::CODE_INVALID_INPUT ,
22
+ 'INVALID_INPUT ' ,
23
+ $ message
24
+ );
25
+ }
9
26
}
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ abstract class AbstractSanitizerProcessor implements Processor
12
12
protected function guardAgainstNonString (mixed $ input ): string
13
13
{
14
14
if (!is_string ($ input )) {
15
- throw new SanitizationException ( ' Input must be a string ' );
15
+ throw SanitizationException:: invalidInput ( ' string ' );
16
16
}
17
17
18
18
return $ input ;
You can’t perform that action at this time.
0 commit comments